CL-USER(37): (dribble) dribbling to file "dribble2" NIL CL-USER(2): (setf list '(1 2 3 4)) (1 2 3 4) CL-USER(3): (cons (+ 1 (car list)) (+ 1 (car (cdr list))) (+ 1 (car (cdr (cdr list)))) (+ 1 (car (cdr (cdr (cdr list)))))) Error: CONS got 4 args, wanted 2 args. [condition type: PROGRAM-ERROR] Restart actions (select using :continue): 0: Return to Top Level (an "abort" restart) 1: Abort # [1] CL-USER(4): :pop CL-USER(5): (cons (+ 1 (car list)) (cons (+ 1 (car (cdr list))) (cons (+ 1 (car (cdr (cdr list)))) (cons (+ 1 (car (cdr (cdr (cdr list))))))))) Error: CONS got 1 arg, wanted 2 args. [condition type: PROGRAM-ERROR] Restart actions (select using :continue): 0: Return to Top Level (an "abort" restart) 1: Abort # [1] CL-USER(6): :pop CL-USER(7): (cons (+ 1 (car list)) (cons (+ 1 (car (cdr list))) (cons (+ 1 (car (cdr (cdr list)))) (cons (+ 1 (car (cdr (cdr (cdr list))))) nil)))) (2 3 4 5) CL-USER(8): (cons (+ 1 (car list)) (let ((r (cdr list))) (cons (+ 1 (car r)) (cons (+ 1 (car (cdr r))) (cons (+ 1 (car (cdr (cdr r)))) nil))))) (2 3 4 5) CL-USER(9): (cons (+ 1 (car list)) (let ((r (cdr list))) (cons (+ 1 (car r)) (let ((s (cdr r))) (cons (+ 1 (car s)) (cons (+ 1 (car (cdr s))) nil)))))) (2 3 4 5) CL-USER(10): (cons (+ 1 (car list)) (let ((r (cdr list))) (cons (+ 1 (car r)) (let ((s (cdr r))) (cons (+ 1 (car s)) (let ((t (cdr s))) (cons (+ 1 (car t)) nil))))))) Error: Cannot bind T -- it is a constant. [condition type: PROGRAM-ERROR] Restart actions (select using :continue): 0: Prompt for a new variable name. 1: Return to Top Level (an "abort" restart) 2: Abort # [1c] CL-USER(11): :pop CL-USER(12): (cons (+ 1 (car list)) (let ((r (cdr list))) (cons (+ 1 (car r)) (let ((s (cdr r))) (cons (+ 1 (car s)) (let ((u (cdr s))) (cons (+ 1 (car u)) nil))))))) (2 3 4 5) CL-USER(13): (defun plus1 (r) (cons (+ 1 (car r)) (plus1 (cdr r)))) PLUS1 CL-USER(14): (plus1 '(1 2 3 4)) Error: `NIL' is not of the expected type `NUMBER' [condition type: TYPE-ERROR] Restart actions (select using :continue): 0: Return to Top Level (an "abort" restart) 1: Abort # [1] CL-USER(15): Error: Received signal number 2 (Keyboard interrupt) [condition type: INTERRUPT-SIGNAL] Restart actions (select using :continue): 0: continue computation at break level 1 1: Return to Top Level (an "abort" restart) 2: Abort # [2c] CL-USER(16): (trace plus1) (PLUS1) [2c] CL-USER(17): (plus1 '(1 2 3 4)) 0: (PLUS1 (1 2 3 4)) 1: (PLUS1 (2 3 4)) 2: (PLUS1 (3 4)) 3: (PLUS1 (4)) 4: (PLUS1 NIL) Error: `NIL' is not of the expected type `NUMBER' [condition type: TYPE-ERROR] Restart actions (select using :continue): 0: Return to Debug Level 2 (an "abort" restart) 1: continue computation at break level 1 2: Return to Top Level (an "abort" restart) 3: Abort # [3] CL-USER(18): :reset 4: returned-by-throwing NIL 3: returned-by-throwing NIL 2: returned-by-throwing NIL 1: returned-by-throwing NIL 0: returned-by-throwing NIL CL-USER(19): (defun plus1 (r) (cons (+ 1 (car r)) (plus1 (cdr r)))) PLUS1 CL-USER(20): (defun plus1 (r) (cond ((endp x) nil) (t (cons (+ 1 (car r)) (plus1 (cdr r)))))) PLUS1 CL-USER(21): (plus1 '(1 2 3 4)) 0: (PLUS1 (1 2 3 4)) Error: Attempt to take the value of the unbound variable `X'. [condition type: UNBOUND-VARIABLE] Restart actions (select using :continue): 0: Try evaluating X again. 1: Use :X instead. 2: Set the symbol-value of X and use its value. 3: Use a value without setting X. 4: Return to Top Level (an "abort" restart) 5: Abort # [1] CL-USER(22): (defun plus1 (r) (cond ((endp r) nil) (t (cons (+ 1 (car r)) (plus1 (cdr r)))))) PLUS1 [1] CL-USER(23): (plus1 '(1 2 3 4)) 1: (PLUS1 (1 2 3 4)) 2: (PLUS1 (2 3 4)) 3: (PLUS1 (3 4)) 4: (PLUS1 (4)) 5: (PLUS1 NIL) 5: returned NIL 4: returned (5) 3: returned (4 5) 2: returned (3 4 5) 1: returned (2 3 4 5) (2 3 4 5) [1] CL-USER(24): (untrace plus1) (PLUS1) [1] CL-USER(25): (plus1 '(1 2 3 4)) (2 3 4 5) CL-USER(2): (setf names '(madge ((allison nil nil) (daria nil nil)) (roger nil nil) (tod sara vera))) (MADGE ((ALLISON NIL NIL) (DARIA NIL NIL)) (ROGER NIL NIL) (TOD SARA VERA)) CL-USER(3): (sdraw names) [*|*]--->[*|*]------------------------------------------->[*|*]--->etc. | | | v v v MADGE [*|*]---------------------------->[*|*]--->NIL etc. | | v v [*|*]---->[*|*]--->[*|*]--->NIL [*|*]--->[*|*]--->[*|*]--->NIL | | | | | | v v v v v v ALLISON NIL NIL DARIA NIL NIL CL-USER(4): (defun find-name (name tree) (cond ((null tree) nil) ((atom tree) (eql name tree)) (t (or (find-name (second tree)) (find-name (third tree)))))) FIND-NAME CL-USER(5): (find-name 'daria names) Error: FIND-NAME got 1 arg, wanted 2 args. [condition type: PROGRAM-ERROR] Restart actions (select using :continue): 0: Return to Top Level (an "abort" restart) 1: Abort # [1] CL-USER(6): :pop CL-USER(7): (defun find-name (name tree) (cond ((null tree) nil) ((atom tree) (eql name tree)) (t (or (find-name name (second tree)) (find-name (third tree)))))) FIND-NAME CL-USER(8): (defun find-name (name tree) (cond ((null tree) nil) ((atom tree) (eql name tree)) (t (or (find-name name (second tree)) (find-name name (third tree)))))) FIND-NAME CL-USER(9): (find-name 'daria names) NIL CL-USER(10): (trace find-name) (FIND-NAME) CL-USER(11): (find-name 'daria names) 0: (FIND-NAME DARIA (MADGE ((ALLISON NIL NIL) (DARIA NIL NIL)) (ROGER NIL NIL) (TOD SARA VERA))) 1: (FIND-NAME DARIA ((ALLISON NIL NIL) (DARIA NIL NIL))) 2: (FIND-NAME DARIA (DARIA NIL NIL)) 3: (FIND-NAME DARIA NIL) 3: returned NIL 3: (FIND-NAME DARIA NIL) 3: returned NIL 2: returned NIL 2: (FIND-NAME DARIA NIL) 2: returned NIL 1: returned NIL 1: (FIND-NAME DARIA (ROGER NIL NIL)) 2: (FIND-NAME DARIA NIL) 2: returned NIL 2: (FIND-NAME DARIA NIL) 2: returned NIL 1: returned NIL 0: returned NIL NIL CL-USER(12): (defun find-name (name tree) (cond ((null tree) nil) ((atom tree) (eql name tree)) (t (or (find-name name (first tree)) (find-name name (second tree)) (find-name name (third tree)))))) FIND-NAME CL-USER(13): (find-name 'daria names) 0: (FIND-NAME DARIA (MADGE ((ALLISON NIL NIL) (DARIA NIL NIL)) (ROGER NIL NIL) (TOD SARA VERA))) 1: (FIND-NAME DARIA MADGE) 1: returned NIL 1: (FIND-NAME DARIA ((ALLISON NIL NIL) (DARIA NIL NIL))) 2: (FIND-NAME DARIA (ALLISON NIL NIL)) 3: (FIND-NAME DARIA ALLISON) 3: returned NIL 3: (FIND-NAME DARIA NIL) 3: returned NIL 3: (FIND-NAME DARIA NIL) 3: returned NIL 2: returned NIL 2: (FIND-NAME DARIA (DARIA NIL NIL)) 3: (FIND-NAME DARIA DARIA) 3: returned T 2: returned T 1: returned T 0: returned T T CL-USER(14): (dtrace find-name) (FIND-NAME) CL-USER(15): (find-name 'daria names) ----Enter FIND-NAME | NAME = DARIA | TREE = (MADGE ((ALLISON NIL NIL) (DARIA NIL NIL)) (ROGER NIL NIL) (TOD SARA VERA)) | ----Enter FIND-NAME | | NAME = DARIA | | TREE = MADGE | \--FIND-NAME returned NIL | ----Enter FIND-NAME | | NAME = DARIA | | TREE = ((ALLISON NIL NIL) (DARIA NIL NIL)) | | ----Enter FIND-NAME | | | NAME = DARIA | | | TREE = (ALLISON NIL NIL) | | | ----Enter FIND-NAME | | | | NAME = DARIA | | | | TREE = ALLISON | | | \--FIND-NAME returned NIL | | | ----Enter FIND-NAME | | | | NAME = DARIA | | | | TREE = NIL | | | \--FIND-NAME returned NIL | | | ----Enter FIND-NAME | | | | NAME = DARIA | | | | TREE = NIL | | | \--FIND-NAME returned NIL | | \--FIND-NAME returned NIL | | ----Enter FIND-NAME | | | NAME = DARIA | | | TREE = (DARIA NIL NIL) | | | ----Enter FIND-NAME | | | | NAME = DARIA | | | | TREE = DARIA | | | \--FIND-NAME returned T | | \--FIND-NAME returned T | \--FIND-NAME returned T \--FIND-NAME returned T T CL-USER(16): (duntrace find-name) (FIND-NAME) CL-USER(17): (trace find-name) (FIND-NAME) CL-USER(18): (find-name 'daria names) 0: (FIND-NAME DARIA (MADGE ((ALLISON NIL NIL) (DARIA NIL NIL)) (ROGER NIL NIL) (TOD SARA VERA))) 1: (FIND-NAME DARIA MADGE) 1: returned NIL 1: (FIND-NAME DARIA ((ALLISON NIL NIL) (DARIA NIL NIL))) 2: (FIND-NAME DARIA (ALLISON NIL NIL)) 3: (FIND-NAME DARIA ALLISON) 3: returned NIL 3: (FIND-NAME DARIA NIL) 3: returned NIL 3: (FIND-NAME DARIA NIL) 3: returned NIL 2: returned NIL 2: (FIND-NAME DARIA (DARIA NIL NIL)) 3: (FIND-NAME DARIA DARIA) 3: returned T 2: returned T 1: returned T 0: returned T T CL-USER(19): (defun rev (list) (cond ((emptyp list) nil) (t (append (rev (rest list)) (list (first list)))))) REV CL-USER(20): (rev '(1 2 3)) Error: attempt to call `EMPTYP' which is an undefined function. [condition type: UNDEFINED-FUNCTION] Restart actions (select using :continue): 0: Try calling EMPTYP again. 1: Return a value instead of calling EMPTYP. 2: Try calling a function other than EMPTYP. 3: Setf the symbol-function of EMPTYP and call it again. 4: Return to Top Level (an "abort" restart) 5: Abort # [1] CL-USER(21): :pop CL-USER(22): (empty nil) Error: attempt to call `EMPTY' which is an undefined function. [condition type: UNDEFINED-FUNCTION] Restart actions (select using :continue): 0: Try calling EMPTY again. 1: Return a value instead of calling EMPTY. 2: Try calling a function other than EMPTY. 3: Setf the symbol-function of EMPTY and call it again. 4: Return to Top Level (an "abort" restart) 5: Abort # [1] CL-USER(23): :pop CL-USER(24): (apropos 'empty) EMPTY EMPTYP EXCL::*EMPTY-ENTRY-MARKER* value: (:EMPTY) FF::EMPTY-FOREIGN-VALUE value: (FF::EMPTY-FOREIGN-VALUE) :EMPTY value: :EMPTY MP:QUEUE-EMPTY-P [generic-function] (QUEUE) CL-USER(25): :pop CL-USER(26): (defun rev (list) (cond ((endp list) nil) (t (append (rev (rest list)) (list (first list)))))) REV CL-USER(27): (rev '(1 2 3)) (3 2 1) CL-USER(28): (trace rev) (REV) CL-USER(29): (rev '(1 2 3)) 0: (REV (1 2 3)) 1: (REV (2 3)) 2: (REV (3)) 3: (REV NIL) 3: returned NIL 2: returned (3) 1: returned (3 2) 0: returned (3 2 1) (3 2 1) CL-USER(30): (defun rev2 (list) (cond ((endp list) nil) (t (nconc (rev2 (rest list)) (list (first list)))))) REV2 CL-USER(31): (rev2 '(1 2 3)) (3 2 1) CL-USER(32): (rev2 (make-list 100)) (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL ...) CL-USER(33): (untrace rev) (REV) CL-USER(34): (rev (make-list 100)) (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL ...) CL-USER(35): (time (rev (make-list 100))) ; cpu time (non-gc) 10 msec user, 0 msec system ; cpu time (gc) 0 msec user, 0 msec system ; cpu time (total) 10 msec user, 0 msec system ; real time 7 msec ; space allocation: ; 7,368 cons cells, 109,888 other bytes, 0 static bytes (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL ...) CL-USER(36): (time (rev2 (make-list 100))) ; cpu time (non-gc) 0 msec user, 0 msec system ; cpu time (gc) 0 msec user, 0 msec system ; cpu time (total) 0 msec user, 0 msec system ; real time 5 msec ; space allocation: ; 2,418 cons cells, 109,888 other bytes, 0 static bytes (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL ...) NIL CL-USER(2): (defun rev2 (list) (cond ((endp list) nil) (t (nconc (rev2 (rest list)) (list (first list)))))) REV2 CL-USER(3): (defun rev (list) (cond ((endp list) nil) (t (append (rev (rest list)) (list (first list)))))) REV CL-USER(4): (setf x (make-list 1000)) (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL ...) CL-USER(5): (time (rev x)) ; cpu time (non-gc) 130 msec user, 40 msec system ; cpu time (gc) 830 msec user, 10 msec system ; cpu time (total) 960 msec user, 50 msec system ; real time 1,015 msec ; space allocation: ; 522,517 cons cells, 1,089,088 other bytes, 76912 static bytes (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL ...) CL-USER(6): (time (rev2 x)) ; cpu time (non-gc) 60 msec user, 0 msec system ; cpu time (gc) 150 msec user, 0 msec system ; cpu time (total) 210 msec user, 0 msec system ; real time 218 msec ; space allocation: ; 23,017 cons cells, 1,089,088 other bytes, 0 static bytes (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL ...) CL-USER(7): (compile-function rev) Error: attempt to call `COMPILE-FUNCTION' which is an undefined function. [condition type: UNDEFINED-FUNCTION] Restart actions (select using :continue): 0: Try calling COMPILE-FUNCTION again. 1: Return a value instead of calling COMPILE-FUNCTION. 2: Try calling a function other than COMPILE-FUNCTION. 3: Setf the symbol-function of COMPILE-FUNCTION and call it again. 4: Return to Top Level (an "abort" restart) 5: Abort # [1] CL-USER(8): :pop CL-USER(9): (compile rev) Error: Attempt to take the value of the unbound variable `REV'. [condition type: UNBOUND-VARIABLE] Restart actions (select using :continue): 0: Try evaluating REV again. 1: Set the symbol-value of REV and use its value. 2: Use a value without setting REV. 3: Return to Top Level (an "abort" restart) 4: Abort # [1] CL-USER(10): :pop CL-USER(11): (compile 'rev) REV NIL NIL CL-USER(12): (compile 'rev2) REV2 NIL NIL CL-USER(13): (time (rev x)) ; cpu time (non-gc) 20 msec user, 0 msec system ; cpu time (gc) 90 msec user, 0 msec system ; cpu time (total) 110 msec user, 0 msec system ; real time 111 msec ; space allocation: ; 500,501 cons cells, 0 other bytes, 0 static bytes (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL ...) CL-USER(14): (time (rev2 x)) ; cpu time (non-gc) 10 msec user, 0 msec system ; cpu time (gc) 0 msec user, 0 msec system ; cpu time (total) 10 msec user, 0 msec system ; real time 7 msec ; space allocation: ; 1,001 cons cells, 0 other bytes, 0 static bytes (NIL NIL NIL NIL NIL NIL NIL NIL NIL NIL ...) CL-USER(15): (dribble)