-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLispOutput.txt
144 lines (111 loc) · 2.42 KB
/
LispOutput.txt
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
ert283@fox02:~$ clisp
i i i i i i i ooooo o ooooooo ooooo ooooo
I I I I I I I 8 8 8 8 8 o 8 8
I \ `+' / I 8 8 8 8 8 8
\ `-+-' / 8 8 8 ooooo 8oooo
`-__|__-' 8 8 8 8 8
| 8 o 8 8 o 8 8
------+------ ooooo 8oooooo ooo8ooo ooooo 8
Welcome to GNU CLISP 2.49 (2010-07-07) <http://clisp.cons.org/>
Copyright (c) Bruno Haible, Michael Stoll 1992, 1993
Copyright (c) Bruno Haible, Marcus Daniels 1994-1997
Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998
Copyright (c) Bruno Haible, Sam Steingold 1999-2000
Copyright (c) Sam Steingold, Bruno Haible 2001-2010
Type :h and hit Enter for context help.
[1]> (load "p3Lisp.txt" :echo T :print T)
;; Loading file p3Lisp.txt ...
(defmacro += (x y)
`(setf ,x (+ ,x ,y))
)
+=
(defmacro iterate (i varA varB varC &rest varRest)
(let ((iter (eval varC))
(compare (eval varB))
)
`(do ((i ,varA (+ i ,iter)))
((> i ,compare))
,@ varRest
)
)
)
ITERATE
;; Loaded file p3Lisp.txt
T
[2]> (load "p3LispRun.txt" :echo T :print T)
;; Loading file p3LispRun.txt ...
;;; p3LispRun.txt begins ...
;; test +=
(setf x 10 y 5)
5
(+= x 5)
15
(print x)
15
15
(+= y x)
20
(print y)
20
20
;; iterate
(iterate i 1 5 1
(print (list 'one i) )
)
(ONE 1)
(ONE 2)
(ONE 3)
(ONE 4)
(ONE 5)
NIL
(setf n 5)
5
(iterate i 1 n 1
(print (list 'two i n))
(+= i 1)
)
(TWO 1 5)
(TWO 3 5)
(TWO 5 5)
NIL
(setf n 5)
5
(iterate i 1 n 1
(print (list 'three i n))
(+= n 1)
)
(THREE 1 5)
(THREE 2 6)
(THREE 3 7)
(THREE 4 8)
(THREE 5 9)
NIL
(setf n 5)
5
(setf inc 2)
2
(iterate i 1 n inc
(print (list 'three i n inc))
(+= inc 1)
)
(THREE 1 5 2)
(THREE 3 5 3)
(THREE 5 5 4)
NIL
(setf n 5)
5
(setf inc 2)
2
(iterate i 1 (+ n 2) inc
(print (list 'four i n inc))
(+= n 1)
(+= i 1)
(+= inc 1)
)
(FOUR 1 5 2)
(FOUR 4 6 3)
(FOUR 7 7 4)
NIL
;; Loaded file p3LispRun.txt
T
[3]>