'Programming > lisp' 카테고리의 다른 글
lisp 예제 (0) | 2014.04.05 |
---|---|
lisp 반복문 dolist, dotimes, do (0) | 2013.01.30 |
lisp cond (0) | 2013.01.28 |
lisp when/unless macro (2) | 2013.01.28 |
lisp 명령어 if progn (0) | 2013.01.28 |
lisp 예제 (0) | 2014.04.05 |
---|---|
lisp 반복문 dolist, dotimes, do (0) | 2013.01.30 |
lisp cond (0) | 2013.01.28 |
lisp when/unless macro (2) | 2013.01.28 |
lisp 명령어 if progn (0) | 2013.01.28 |
lisp 키 입력 (0) | 2015.07.19 |
---|---|
lisp 반복문 dolist, dotimes, do (0) | 2013.01.30 |
lisp cond (0) | 2013.01.28 |
lisp when/unless macro (2) | 2013.01.28 |
lisp 명령어 if progn (0) | 2013.01.28 |
> (dolist (a '(1 2 3)) (print a)) 1
2
3
NIL
|
> (dotimes (i 4) (print i))
0
1
2
3
NIL
|
> (dotimes (i 4) (if (= i 3) (return T) (print i))) 0
1
2
T |
> (dotimes (x 20)
(dotimes (y 20)
(format t "~3d " (* (1+ x) (1+ y))))
(format t "~%"))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 51 54 57 60
4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100
6 12 18 24 30 36 42 48 54 60 66 72 78 84 90 96 102 108 114 120
7 14 21 28 35 42 49 56 63 70 77 84 91 98 105 112 119 126 133 140
8 16 24 32 40 48 56 64 72 80 88 96 104 112 120 128 136 144 152 160
9 18 27 36 45 54 63 72 81 90 99 108 117 126 135 144 153 162 171 180
10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200
11 22 33 44 55 66 77 88 99 110 121 132 143 154 165 176 187 198 209 220
12 24 36 48 60 72 84 96 108 120 132 144 156 168 180 192 204 216 228 240
13 26 39 52 65 78 91 104 117 130 143 156 169 182 195 208 221 234 247 260
14 28 42 56 70 84 98 112 126 140 154 168 182 196 210 224 238 252 266 280
15 30 45 60 75 90 105 120 135 150 165 180 195 210 225 240 255 270 285 300
16 32 48 64 80 96 112 128 144 160 176 192 208 224 240 256 272 288 304 320
17 34 51 68 85 102 119 136 153 170 187 204 221 238 255 272 289 306 323 340
18 36 54 72 90 108 126 144 162 180 198 216 234 252 270 288 306 324 342 360
19 38 57 76 95 114 133 152 171 190 209 228 247 266 285 304 323 342 361 380
20 40 60 80 100 120 140 160 180 200 220 240 260 280 300 320 340 360 380 400
NIL
|
> (do ((i 0 (1+ i)))
((>= i 4))
(print i))
0
1
2
3
NIL
|
lisp 키 입력 (0) | 2015.07.19 |
---|---|
lisp 예제 (0) | 2014.04.05 |
lisp cond (0) | 2013.01.28 |
lisp when/unless macro (2) | 2013.01.28 |
lisp 명령어 if progn (0) | 2013.01.28 |
(cond ((조건문) 참일경우 실행) ((조건문) 참일경우 실행) ... ((조건문) 참일경우 실행)) |
> (setq a 5)
> (cond ((eq a 'hack) 'foo)
(t "default"))
"default"
> (cond ((eq a 5) 'foo)
(t "test"))
FOO
> (cond
((eq a 0) 'foo)
((eq a 5) 'bar)
(t "test"))
BAR
> (cond
(t "test")
((eq a 0) 'foo)
((eq a 5) 'bar))
"test" |
lisp 예제 (0) | 2014.04.05 |
---|---|
lisp 반복문 dolist, dotimes, do (0) | 2013.01.30 |
lisp when/unless macro (2) | 2013.01.28 |
lisp 명령어 if progn (0) | 2013.01.28 |
lisp eval & apply (0) | 2013.01.22 |
lisp 반복문 dolist, dotimes, do (0) | 2013.01.30 |
---|---|
lisp cond (0) | 2013.01.28 |
lisp 명령어 if progn (0) | 2013.01.28 |
lisp eval & apply (0) | 2013.01.22 |
xlisp에서 incf 오류 (0) | 2013.01.19 |
> (if (< 1 2) 'A 'B)
A
> (if (< 1 2) (if (< 1 2) 'C 'D) 'B)
C
|
[10]> (progn (print "The first form")
(print "The second form")
(print "The third form"))
"The first form"
"The second form"
"The third form"
"The third form"
[11]> (prog1 (print "The first form")
(print "The second form")
(print "The third form"))
"The first form"
"The second form"
"The third form"
"The first form"
[12]> (prog2 (print "The first form")
(print "The second form")
(print "The third form"))
"The first form"
"The second form"
"The third form"
"The second form" |
> (if (> 2 3) (progn (print "i am a boy") (print "you are a girl"))
(progn (print "tt") (print"aa")))
"tt"
"aa"
"aa"
|
lisp cond (0) | 2013.01.28 |
---|---|
lisp when/unless macro (2) | 2013.01.28 |
lisp eval & apply (0) | 2013.01.22 |
xlisp에서 incf 오류 (0) | 2013.01.19 |
lisp backquote / 유사인용 (0) | 2013.01.19 |
> (eval (+ 1 2))
3
> (eval '(+ 1 2))
3
>
|
> (apply (function +) '(1 2))
3
> (apply + '(1 2))
error: bad function - (apply (function +) (quote (1 2)))
|
evaluate an xlisp expression
(eval <expr>)
<expr> the expression to be evaluated
returns the result of evaluating the expression
apply a function to a list of arguments
(apply <fun> <arg>...<args>)
<fun> the function to apply (or function symbol). May not be macro or fsubr.
<arg> initial arguments, which are consed to...
<args> the argument list
returns the result of applying the function to the arguments |
lisp when/unless macro (2) | 2013.01.28 |
---|---|
lisp 명령어 if progn (0) | 2013.01.28 |
xlisp에서 incf 오류 (0) | 2013.01.19 |
lisp backquote / 유사인용 (0) | 2013.01.19 |
lisp rem, mod (0) | 2013.01.17 |
increment a field
(incf <place> [<value>])
decrement a field
(decf <place> [<value>])
defined as macro in common.lsp. Only evaluates place form arguments one time. It is recommended that *displace-macros* be non-nil for best performance.
<place> field specifier being modified (see setf)
<value> Numeric value (default 1)
returns the new value which is (+ <place> <value>) or (- <place> <value>)
|
> (setq a 1)
1
> (incf a)
error: unbound function - incf
if continued: try evaluating symbol again |
[9]> (setq a 1)
1
[10]> (incf a)
2
[11]> a
2
|
lisp 명령어 if progn (0) | 2013.01.28 |
---|---|
lisp eval & apply (0) | 2013.01.22 |
lisp backquote / 유사인용 (0) | 2013.01.19 |
lisp rem, mod (0) | 2013.01.17 |
lisp i/o (0) | 2013.01.17 |
> (defun tt-path (edge)
'(there is a ,(caddr edge) going, (cadr edge) from here.))
tt-path
> (tt-path '(garden west door))
(there is a (comma (caddr edge)) going (comma (cadr edge)) from here.)
|
> (defun t2-path (edge)
`(there is a ,(caddr edge) going, (cadr edge) from here.))
t2-path
> (t2-path '(garden west door))
(there is a door going west from here.)
|
lisp eval & apply (0) | 2013.01.22 |
---|---|
xlisp에서 incf 오류 (0) | 2013.01.19 |
lisp rem, mod (0) | 2013.01.17 |
lisp i/o (0) | 2013.01.17 |
lisp file i/o (0) | 2013.01.17 |
2> (mod 5 2)
1
2> (mod 5 -2)
-1
2> (rem 5 2)
1
2> (rem 5 -2)
1 |
Rem(x, 5): 5+ o o | / / | / / | / / | / / *---------*---------*---------*---------* -10 / -5 / 0 5 10 / / | / / | / / | o o -5+ Mod(x, 5): o 5o o o / / | / / / / | / / / / | / / / / | / / *---------*---------*---------*---------* -10 -5 0 5 10 Rem(x, -5): 5+ o o | / / | / / | / / | / / *---------*---------*---------*---------* -10 / -5 / 0 5 10 / / | / / | / / | o o -5+ Mod(x, -5): *---------*---------*---------*---------* -10 / -5 / 0 / 5 /10 / / | / / / / | / / / / | / / o o -5o o[링크 : http://mathforum.org/library/drmath/view/54377.html] |
xlisp에서 incf 오류 (0) | 2013.01.19 |
---|---|
lisp backquote / 유사인용 (0) | 2013.01.19 |
lisp i/o (0) | 2013.01.17 |
lisp file i/o (0) | 2013.01.17 |
lisp savefun / load (0) | 2013.01.16 |