-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCharpter11.bak
59 lines (35 loc) · 946 Bytes
/
Charpter11.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#|【Scheme Basic Functions by Kevin&poi~】|#
;function: ture if input is a vowel, false if not.
;argument: 1 character
(define (vowel? char)
(member? char '(a e i o u)))
;square the number
;argument: 1 number
(define (square num)
(* num num))
;cube the number
;argument: 1 number
(define (cube num)
(* num num num))
;find the second word/character in a string/word
;argument: word/string
(define (second x)
(first (bf x)))
;reverse the order of the word
;argument:word
(define (reverse_order wd)
(accumulate (lambda (x y)(word y x))wd))
(define (downup2 wd)
(se wd (word (first wd) (second wd))(first wd)))
(define (downup wd)
(if (= (count wd) 1)
(se wd)
(se wd (downup (bl wd))wd)))
(define (explode wd)
(if ( = (count wd) 0)
()
(se (first wd)(explode (bf wd)))))
(define (pairs wd)
(if (<= (count wd) 1)
()
(se (word(first wd)(second wd))(pairs (bf wd)))))