blob: 25a23cfcedb49647c71737698d0b4923c2ec04a3 (
plain)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
(set 'success t)
(defun test (test-expr res)
(newline)
(princ
(list (fill ((differ (eval test-expr) res) '+)
('f 'fail))
'--> test-expr))
(and success
(set 'success (fill ((differ (eval test-expr) res) t)
(f f)))))
;; atom
(test '(atom ()) f)
(test '(atom 'a) t)
(test '(atom '(x . a)) f)
(test '(atom '(x a)) f)
;(test '(atom 'a) undef)
;; dif
(test '(dif () 'b) t)
(test '(dif () ()) f)
(test '(dif 'a 'b) t)
(test '(dif 'a 'a) f)
(test '(dif 'a '(b . c)) t)
(test '(dif 'a '(b c)) t)
(test '(dif '(b . c) '(b . c)) t)
(test '(dif '(b c) '(b c)) t)
;; differ
(test '(differ 'a ()) t)
(test '(differ () ()) f)
(test '(differ 'a '(b c)) t)
(test '(differ '(a b) '(b c)) t)
(test '(differ '(b . c) '(b . c)) f)
(test '(differ '(b c) '(b c)) f)
;; car
(test '(car ()) ())
(test '(car '(a)) 'a)
(test '(car '(a . b)) 'a)
(test '(car '(a b)) 'a)
(test '(car '((a . b) . c)) '(a . b))
;(test '(car 'a) undef)
;; cdr
(test '(cdr ()) ())
(test '(cdr '(a)) ())
(test '(cdr '(a . b)) 'b)
(test '(cdr '(a b)) '(b))
(test '(cdr '((a . b) . c)) 'c)
;(test '(cdr 'a) undef)
;; cons
(test '(cons 'a ()) '(a))
(test '(cons 'a 'b) '(a . b))
(test '(cons 'a '(b)) '(a b))
(test '(cons '(a . b) 'c) '((a . b) . c))
;; or
(test '(or () 'a) ())
(test '(or t 'a) t)
(test '(or 'a 'b 'c) 'a)
(test '(or f f t) t)
(test '(or t (car 'a)) t)
;(test '(or (car 'a) t) undef)
;; and
(test '(and () 'a) 'a)
(test '(and f 'a) f)
(test '(and 'a 'b 'c) 'c)
(test '(and t t f) f)
(test '(and f (car 'a)) f)
;(test '(and (car 'a) f) undef)
;; cond
(test '(cond (() 'a) (f 'b)) 'a)
(test '(cond (t 'a) (f 'b)) 'a)
(test '(cond (f 'a) (t 'b) (t 'c)) 'b)
(test '(cond (f 'a) (t 'b)) 'b)
(test '(cond (f (car 'a)) (t 'b)) 'b)
;(test '(cond (f 'a) (t (car 'a))) undef)
(test '(cond (f 'a) (f 'b)) n)
;; fill
(test '(fill (() 'a) (f 'b)) 'b)
(test '(fill (f 'a) (t 'b)) 'a)
(test '(fill (t 'a) (f 'b) (f 'c)) 'b)
(test '(fill (t 'a) (f 'b)) 'b)
(test '(fill (t (car 'a)) (f 'b)) 'b)
;(test '(fill (t 'a) (f (car 'a))) undef)
(test '(fill (t 'a) (t 'b)) n)
;; final message
(and success (prog
(newline)
(princ '(All with success.))
(newline)))
(defmacro clean (x) (newline) (princ '(** macro clean:)) (newline) (print x) (newline) (print x) (newline))
(defmacro mac (x) (newline) (princ '(** macro:)) (newline) (print x) (newline) (print (eval x)) (newline))
(defmacro macr (x) (newline) (princ '(** macro reverse:)) (newline) (print (eval x)) (newline) (print x) (newline))
(defmacro double (x) (newline) (princ '(** double:)) (newline) (print (eval (eval x))) (newline))
(defun fun (x) (newline) (princ '(** function:)) (newline) (print x) (newline) (print (eval x)) (newline))
(defun fun1 (x) (newline) (princ '(** function reverse:)) (newline) (print (eval x)) (newline) (print x) (newline))
(newline)
(princ '(TEST (and t t f)))
(newline)
(princ '(- unquoted))
(newline)
(clean (and t t f))
(mac (and t t f))
(macr (and t t f))
(double (and t t f))
(fun (and t t f))
(fun1 (and t t f))
(princ '(- quoted))
(newline)
(clean '(and t t f))
(mac '(and t t f))
(macr '(and t t f))
(double '(and t t f))
(fun '(and t t f))
(fun1 '(and t t f))
|