아래는 GNU CLisp 로 실행한 것인데. Clozure CL 로 실행해도 거의 같은 결과를 얻는다.
명령프롬프트> 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]> (setf x #c(1 (/ 2.0 3.0))
*** - READ from
#<INPUT CONCATENATED-STREAM #<INPUT STRING-INPUT-STREAM>
#<IO TERMINAL-STREAM>>
: bad syntax for complex number: #C(1 (/ 2.0 3.0))
The following restarts are available:
ABORT :R1 Abort main loop
Break 1 [2]> (setf z (complex 1 (/ 2.0 3.0)))
#C(1 0.6666667)
Break 1 [2]> (setf y (/ 2.0 3.0))
0.6666667
Break 1 [2]> (setf z (complex 1 y))
#C(1 0.6666667)
Break 1 [2]> z
#C(1 0.6666667)
Break 1 [2]> (setf z (complex 1 (/ 2.0 3)))
#C(1 0.6666667)
Break 1 [2]> (setf z (- (complex 1 (/ 2.0 3))))
#C(-1 -0.6666667)
Break 1 [2]> z
#C(-1 -0.6666667)
Break 1 [2]> (realpart z)
-1
Break 1 [2]> (imagpart z)
-0.6666667
Break 1 [2]> (conjugate z)
#C(-1 0.6666667)
Break 1 [2]> (- z)
#C(1 0.6666667)
Break 1 [2]> (1- z)
#C(-2 -0.6666667)
Break 1 [2]> (1+ z)
#C(0 -0.6666667)
Break 1 [2]> (zerop z)
NIL
Break 1 [2]> (zerop (- z z))
T
Break 1 [2]> (zerop (+ z (- z)))
T
Break 1 [2]> (abs z)
1.2018504
Break 1 [2]> (sqrt z)
#C(0.31768727 -1.0492499)
Break 1 [2]> (zerop (+ z (- z)))
T
Break 1 [2]> (* z (conjuate z))
*** - EVAL: undefined function CONJUATE
The following restarts are available:
USE-VALUE :R1 Input a value to be used instead of (FDEFINITION 'CONJUA
TE).
RETRY :R2 Retry
STORE-VALUE :R3 Input a new value for (FDEFINITION 'CONJUATE).
ABORT :R4 Abort debug loop
ABORT :R5 Abort main loop
Break 2 [3]> (* z (conjugate z))
#C(1.4444444 0.0)
Break 2 [3]> (defun distance-from-origin(z)
(realpart (sqrt (* z (conjugate z)))))
DISTANCE-FROM-ORIGIN
Break 2 [3]> (distance-from-origin z)
1.2018504
Break 2 [3]> ((distance-from-origin z) (abs z))
*** - EVAL: (DISTANCE-FROM-ORIGIN Z) is not a function name; try using a
symbol instead
The following restarts are available:
USE-VALUE :R1 Input a value to be used instead.
ABORT :R2 Abort debug loop
ABORT :R3 Abort debug loop
ABORT :R4 Abort main loop
Break 3 [4]> (= (distance-from-origin z) (abs z))
T
Break 3 [4]> (- (distance-from-origin z) (abs z))
0.0
Break 3 [4]> (= (distance-from-origin z) (sqrt (+ (* (realpart z)
(realpart z)) (* (imagpart z) (imagpart z)))))
T
Break 3 [4]> (- (distance-from-origin z) (sqrt (+ (* (realpart z)
(realpart z)) (* (imagpart z) (imagpart z)))))
0.0
Break 3 [4]> (sin z)
#C(-1.0354936 -0.38748237)
Break 3 [4]> (cos z)
#C(0.66488284 -0.60346806)
Break 3 [4]> (tan z)
#C(-0.56391037 -1.0946053)
Break 3 [4]> (asin z)
#C(-0.8048969 -0.85406184)
Break 3 [4]> (acos z)
#C(2.3756933 0.85406184)
Break 3 [4]> (atan z)
#C(-0.89473265 -0.30594388)
Break 3 [4]> (sinh z)
#C(-0.92357564 -0.9541945)
Break 3 [4]> (cosh z)
#C(1.2126874 0.72670895)
Break 3 [4]> (tanh z)
#C(-0.9072973 -0.2431405)
Break 3 [4]> (asinh z)
#C(-0.9614137 -0.4609276)
Break 3 [4]> (acosh z)
#C(0.8540618 -2.375693)
Break 3 [4]> (atanh z)
#C(-0.5756463 -0.94627345)
Break 3 [4]> (log z)
#C(0.1838624 -2.55359)
Break 3 [4]> (exp z)
#C(0.28911176 -0.22748554)
Break 3 [4]> (log (exp z))
#C(-1.0 -0.6666667)
Break 3 [4]> (exp (log z))
#C(-1.0 -0.6666667)
Break 3 [4]> (expt 2 z)
#C(0.44755954 -0.22291358)
Break 3 [4]> (expt z 2)
#C(0.5555555 1.3333334)
Break 3 [4]> (* z z)
#C(0.5555555 1.3333334)
Break 3 [4]> (quit)
Bye.
'프로그래밍 > Common Lisp' 카테고리의 다른 글
Common Lisp 언어로 역삼각함수, 역쌍곡선함수 값을 구하는 예제 (0) | 2013.09.11 |
---|---|
감마함수(gamma function)의 값을 (유효수자 15자리 까지 정밀하게) 계산하는 Common Lisp 언어 소스 (0) | 2013.09.08 |
Common Lisp 를 이용한 간단한 수학식 계산하기 (0) | 2013.09.07 |
조립제법(Horner의 방법) 예제 2 for Common Lisp (0) | 2013.09.07 |
숫자 맞추기 게임 with Common Lisp (0) | 2013.09.07 |