-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlearning0.lisp
195 lines (192 loc) · 6.01 KB
/
learning0.lisp
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
; SLIME 2011-02-04
CL-USER> (defun print-list(list)(dolist (i list)(format t "item: ~a~%" i)))
PRINT-LIST
CL-USER> (pirnt-list (list 1 2 3))
Invoking restart: Return to SLIME's top level.
; Evaluation aborted on #<CCL::UNDEFINED-FUNCTION-CALL #x187A07B6>.
CL-USER> (print-list (list 1 2 3))
item: 1
item: 2
item: 3
NIL
CL-USER> (defun foo(n)(dotmes ( i 10)(dotimes j 10)(when (> (* i j) n)(return-from foo(list i j)))))
Invoking restart: Kill this thread
; Evaluation aborted on #<CCL::SIMPLE-PROGRAM-ERROR #x1879137E>.
CL-USER> (defun foo(n)
(dotimes (i 10)
(dotimes (j 10)
(when (> (* i j) n)
(return-from foo(list i j))))))
FOO
CL-USER> (foo 23)
(3 8)
CL-USER> (defun foo()(list 1 2 3))
FOO
CL-USER> (foo 1 2 3)
Invoking restart: Kill this thread
; Evaluation aborted on #<CCL::TOO-MANY-ARGUMENTS #x187B4ACE>.
CL-USER> (foo)
(1 2 3)
CL-USER> #'foo
#<Compiled-function FOO #x187B501E>
CL-USER> (defun foo(x)(* x 2))
FOO
CL-USER> (foo 1 2 3)
Invoking restart: Kill this thread
; Evaluation aborted on #<CCL::TOO-MANY-ARGUMENTS #x187CC3DE>.
CL-USER> #'foo
#<Compiled-function FOO #x187C4C2E>
CL-USER> (funcall #'foo 1 2 3)
Invoking restart: Kill this thread
; Evaluation aborted on #<CCL::TOO-MANY-ARGUMENTS #x187DAB2E>.
CL-USER> (defun plot(fn min max step)(loop for i from min to max by step do (loop repeat (funcall fn i)(format t "*")(format t "~%"))))
Invoking restart: Kill this thread
; Evaluation aborted on #<CCL::SIMPLE-PROGRAM-ERROR #x187F95BE>.
CL-USER> (defun plot(fn min max step)
(loop for i from min to max by step do
(loop repeat (funcall fn i)
(format t "*")
(format t "~%"))))
Invoking restart: Kill this thread
; Evaluation aborted on #<CCL::SIMPLE-PROGRAM-ERROR #x1881A906>.
CL-USER> (defun plot(fn min max step)
(loop for i from min to max by step do
(loop repeat (funcall fn i)
(format t "*"))
(format t "~%")))
Invoking restart: Kill this thread
; Evaluation aborted on #<CCL::SIMPLE-PROGRAM-ERROR #x18837B46>.
CL-USER> (defun plot(fn min max step)
(loop for i from min to max by step do
(loop repeat (funcall fn i)(format t "*"))
(format t "~%")))
Invoking restart: Kill this thread
; Evaluation aborted on #<CCL::SIMPLE-PROGRAM-ERROR #x18851E46>.
CL-USER> (defun plot(fn min max step)
(loop for i from min to max by step do
(loop repeat (funcall fn i)(format t "*"))
(format t "~%")))
Invoking restart: Kill this thread
; Evaluation aborted on #<CCL::SIMPLE-PROGRAM-ERROR #x1887055E>.
CL-USER> (defun plot(fn min max step)
(loop for i from min to max by step do
(loop repeat (funcall fn i) do (format t "*"))
(format t "~%")))
PLOT
CL-USER> (plot #'exp(1 2 4 5))
Invoking restart: Kill this thread
; Evaluation aborted on #<CCL::SIMPLE-PROGRAM-ERROR #x1876FCAE>.
CL-USER> (plot #'exp 1 2 4)
**
NIL
CL-USER> (plot #'exp 4 2 1/2)
NIL
CL-USER> (plot #'exp 0 4 1/2)
*
*
**
****
*******
************
********************
*********************************
******************************************************
NIL
CL-USER> (apple plot plot-data)
Invoking restart: Return to SLIME's top level.
; Evaluation aborted on #<UNBOUND-VARIABLE #x1878D6BE>.
CL-USER> (apply #'plot plot-data)
Invoking restart: Return to SLIME's top level.
; Evaluation aborted on #<UNBOUND-VARIABLE #x187A1566>.
CL-USER> (apply #'plot plot-data)
Invoking restart: Return to SLIME's top level.
; Evaluation aborted on #<UNBOUND-VARIABLE #x187B7726>.
CL-USER> (apply plot #'exp plot-data)
Invoking restart: Return to SLIME's top level.
; Evaluation aborted on #<UNBOUND-VARIABLE #x187CAE5E>.
CL-USER> (funcall #'(lambda(x)(+ x y)( 2 3)))
Invoking restart: Kill this thread
; Evaluation aborted on #<CCL::COMPILE-TIME-PROGRAM-ERROR #x187E2BCE>.
CL-USER> (funcall #'(lambda(x)(+ x y)) 2 3)
;Compiler warnings :
; In an anonymous lambda form: Undeclared free variable Y
Invoking restart: Kill this thread
; Evaluation aborted on #<CCL::TOO-MANY-ARGUMENTS #x187F70F6>.
CL-USER> (funcall #'lambda(x y)(+ x y)2 3)
Invoking restart: Kill this thread
; Evaluation aborted on #<UNDEFINED-FUNCTION #x18805F16>.
CL-USER> (funcall #'(lambda(x y)(+ x y)) 2 3)
5
CL-USER> ((lambda(x)(+ x y)) 2 3)
;Compiler warnings :
; In an anonymous lambda form: Undeclared free variable Y
Invoking restart: Kill this thread
; Evaluation aborted on #<CCL::TOO-MANY-ARGUMENTS #x18823E2E>.
CL-USER> ((lambda(x y)(+ x y)) 2 3 )
5
CL-USER> (defun double(x)(* x 2))
DOUBLE
CL-USER> (plot #'double 0 10 1)
**
****
******
********
**********
************
**************
****************
******************
********************
NIL
CL-USER> (plot #'(lambda(x)(* x 2) 0 10 1))
Invoking restart: Kill this thread
; Evaluation aborted on #<CCL::TOO-FEW-ARGUMENTS #x1883A146>.
CL-USER> (plot #'(lambda(x)(* x 2)) 0 10 1)
**
****
******
********
**********
************
**************
****************
******************
********************
NIL
CL-USER> (defun plot(fn min max step)(loop for i from min to max by step do (loop (funcall fn i))(format t "*")(format t "~%")))
PLOT
CL-USER> (defun plot(fn min max step)(llop for i form min to max by step do (loop repeat(funcall fn i) do (format t "*"))(format t "~%")))
;Compiler warnings :
; In PLOT: Undefined function LLOP
; In PLOT: Undeclared free variable FOR
; In PLOT: Undeclared free variable FORM
; In PLOT: Undeclared free variable TO
; In PLOT: Undeclared free variable BY
; In PLOT: Undeclared free variable DO
; In PLOT: Undeclared free variable I (2 references)
PLOT
CL-USER> (defun plot(fn min max step)(loop for i from min to max by step do (loop repeat(funcall fn i) do (format t "*"))(format t "~%")))
PLOT
CL-USER> ((lambda(x y)(+ x y)) 2 3)
5
CL-USER> (funcall #'(lambda(x y)(+ x y)) 2 3)
5
CL-USER> (plot #'(lambda(x)(* x 2) 0 10 1))
Invoking restart: Kill this thread
; Evaluation aborted on #<CCL::TOO-FEW-ARGUMENTS #x1878D87E>.
CL-USER> (plot #'(lambda(x)(* x 2)) 0 10 1)
**
****
******
********
**********
************
**************
****************
******************
********************
NIL
CL-USER> (+ a 1)
Invoking restart: Return to SLIME's top level.
; Evaluation aborted on #<UNBOUND-VARIABLE #x187A6F4E>.
CL-USER>