-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchapter01.scm
79 lines (41 loc) · 1.17 KB
/
chapter01.scm
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
(define atom?
(lambda (x)
(and (not (pair? x)) (not (null? x)))))
(atom? 'atom)
(atom? 'turkey)
(atom? 1492)
(atom? 'u)
(atom? '*abc$)
(list? '(atom))
(list? '(atom turkey or))
(list? '((atom turkey) or))
(car '(a b c))
(car '(((hotdogs)) (and) (pickle) relish))
(car '(((hotdogs)) (and)))
(cdr '(hamburger))
(cdr '((x) t r))
(cdr 'hotdogs)
(car (cdr '((b) (x y) ((c)))))
(cdr (cdr '((b) (x y) ((c)))))
(cons 'peanut '(butter and jelly))
(cons '(banana and) '(peanut butter and jelly))
(cons '((help) this) '(is very ((hard) to learn)))
(cons '(a b (c)) ())
(cons '((a b c)) 'b)
(cons 'a (car '((b) c d)))
(cons 'a (cdr '((b) c d)))
(atom? 'Harry)
(atom? '(Harry had a heap of apples))
(atom? (car '(Harry had a heap of apples)))
(atom? (cdr '(Harry had a heap of apples)))
(atom? (cdr '(Harry)))
(atom? (car (cdr '(swing low sweet cherry oat))))
(atom? (car (cdr '(swing (low sweet) cherry oat))))
(eq? 'Harry 'Harry)
(eq? 'margarine 'butter)
(eq? '() '(strawberry))
(eq? 6 7)
(eq? (car '(Mary had a little lamb chop)) 'Mary)
(eq? (cdr '(soured milk)) 'milk)
(eq? (car '(beans beans we need jelly beans)) (car (cdr '(beans beans
we need jelly beans))))