Janusz Podrazik <
info@mracpublishing.com> writes:
I may did not explain correctly.
This should explain.
In CLOZURE (or MCL)
(defun addup (x y)
(+ x y))
=> ADDUP
(addup 1 1)
=> 2
;(addup 1 2)
=> 3
(+ 1
(+ 1
(+ 1 0) ;=> 1
) ;=> 2
) ;=> 3
;(+ 1 0) ;= 1
In LISPWORKS 6
(defun addup (x y)
(+ x y))
=> ADDUP
(addup 1 1)
=> 2
;(addup 1 2)
=> 2
(+ 1
(+ 1
(+ 1 0) ;=> 3
) ;=> 3
) ;=> 3
;(+ 1 0) ;= 3
It doesn't explain anything. If you could put some words on it, it'd go
better...
If you wannt to see intermediary results, you may use TRACE.
(Unfortunately, it doesn't work conformingly on CL functions, only
yours. However, it's possible that Lispworks an/or CCL TRACE work on CL
functions too).
CL-USER> (trace +)
WARNING: TRACE: redefining function + in top-level, was defined in C
;; Tracing function +.
(+)
CL-USER> (+ 1 (+ 1 (+ 1 0)))
1. Trace: (+ '1 '0)
1. Trace: + ==> 1
1. Trace: (+ '1 '1)
1. Trace: + ==> 2
1. Trace: (+ '1 '2)
1. Trace: + ==> 3
3
CL-USER> (untrace +)
(+)
CL-USER>
You may also use STEP to do it interactively.
CL-USER> (step (+ 1 (+ 1 (+ 1 0))))
step 1 --> (+ 1 (+ 1 (+ 1 0)))
C/Step 1 USER[2]> :s
step 2 --> 1
C/Step 2 USER[3]> :s
step 2 ==> value: 1
step 2 --> (+ 1 (+ 1 0))
C/Step 2 USER[4]> :s
step 3 --> 1
C/Step 3 USER[5]> :s
step 3 ==> value: 1
step 3 --> (+ 1 0)
C/Step 3 USER[6]> :s
step 4 --> 1
C/Step 4 USER[7]> :s
step 4 ==> value: 1
step 4 --> 0
C/Step 4 USER[8]> :s
step 4 ==> value: 0
step 3 ==> value: 1
step 2 ==> value: 2
step 1 ==> value: 3
3
CL-USER>
--
__Pascal Bourguignon__
http://www.informatimago.com/
A bad day in () is better than a good day in {}.