;; Dribble of # started on NIL. # [5]> (defun func2 (x) (* x x)) FUNC2 [6]> (defun func3 (x) (* x x x)) FUNC3 [7]> (defun dofunc (fn x) (fn x)) DOFUNC [8]> (dofunc 'func2 5) *** - EVAL: undefined function FN The following restarts are available: USE-VALUE :R1 Input a value to be used instead of (FDEFINITION 'FN). RETRY :R2 Retry STORE-VALUE :R3 Input a new value for (FDEFINITION 'FN). ABORT :R4 Abort main loop Break 1 [9]> abort [10]> (defun dofunc (fn x) (apply fn x)) DOFUNC [11]> (dofunc 'func2 '(5)) 25 [12]> (dofunc 'func3 '(5)) 125 [13]> (defun func6 (x) (* x x x x x x)) FUNC6 [14]> (dofunc 'func6 '(5)) 15625 [15]> (defun dofunc (fn x) (+ 5 (apply fn x))) DOFUNC [16]> (dofunc 'func2 '(5)) 30 [17]> (dofunc 'func3 '(5)) 130 [18]> (dofunc 'func6 '(5)) 15630 [19]> (defun dofunc (fn x) (+ 5 (funcall fn x))) DOFUNC [20]> (dofunc 'func6 '5) 15630 [21]> (dofunc 'func2 '5) 30 [22]> (dofunc 'func3 '5) 130 [23]> (+ 1 2 3 4 5) 15 [24]> (apply '+ (1 2 3 4 5)) *** - EVAL: 1 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 main loop Break 1 [25]> abort [26]> (apply '+ '(1 2 3 4 5)) 15 [27]> (apply '* '(1 2 3 4 5)) 120 [28]> (apply 'cadr '(1 2 3 4 5)) *** - APPLY: too many arguments given to CADR The following restarts are available: ABORT :R1 Abort main loop Break 1 [29]> abort [30]> (apply 'cadr '((1 2 3 4 5))) 2 [31]> (funcall 'cadr '(1 2 3 4 5)) 2 [32]> (defun sum-loop (func x) (+ (apply func (list x)) (sum-loop (1- x)))) SUM-LOOP [33]> (sum-loop 'func2 5) *** - EVAL/APPLY: too few arguments given to SUM-LOOP The following restarts are available: ABORT :R1 Abort main loop Break 1 [34]> abort [35]> (defun sum-loop (func x) (+ (apply func (list x)) (sum-loop func (1- x)))) SUM-LOOP [36]> (sum-loop 'func2 5) [37]> (defun sum-loop (func x) (if (zerop x) 1 (+ (apply func (list x)) (sum-loop func (1- x))))) SUM-LOOP [38]> (sum-loop 'func2 5) 56 [39]> (sum-loop 'func6 5) 20516 [40]> () NIL [41]> (eval '(+ 1 2 3)) 6 [42]> (setq prog1 '(sum-loop 'func6 7)) (SUM-LOOP 'FUNC6 7) [43]> prog1 (SUM-LOOP 'FUNC6 7) [44]> prog1 (SUM-LOOP 'FUNC6 7) [45]> (eval prog1) 184821 [46]> (setq prog2 '(sum-loop 'func3 8)) (SUM-LOOP 'FUNC3 8) [47]> prog1 (SUM-LOOP 'FUNC6 7) [48]> prog2 (SUM-LOOP 'FUNC3 8) [49]> (eval prog2) 1297 [50]> (mapcar '1+ '(100 200 300)) (101 201 301) [51]> (mapcar 'prog6 '(1 2 3 4 5)) *** - FUNCALL: undefined function PROG6 The following restarts are available: USE-VALUE :R1 Input a value to be used instead of (FDEFINITION 'PROG6). RETRY :R2 Retry STORE-VALUE :R3 Input a new value for (FDEFINITION 'PROG6). ABORT :R4 Abort main loop Break 1 [52]> abort [53]> (mapcar 'func6 '(1 2 3 4 5)) (1 64 729 4096 15625) [54]> (appy '+ (mapcar 'func6 '(1 2 3 4 5))) *** - EVAL: undefined function APPY The following restarts are available: USE-VALUE :R1 Input a value to be used instead of (FDEFINITION 'APPY). RETRY :R2 Retry STORE-VALUE :R3 Input a new value for (FDEFINITION 'APPY). ABORT :R4 Abort main loop Break 1 [55]> abort [56]> (apply '+ (mapcar 'func6 '(1 2 3 4 5))) 20515 [57]> (+ (mapcar 'func6 '(1 2 3 4 5)) ) *** - +: (1 64 729 4096 15625) is not a number The following restarts are available: USE-VALUE :R1 Input a value to be used instead. ABORT :R2 Abort main loop Break 1 [58]> (+ '(1 2 3)) *** - +: (1 2 3) is not a number The following restarts are available: USE-VALUE :R1 Input a value to be used instead. ABORT :R2 Abort debug loop ABORT :R3 Abort main loop Break 2 [59]> abort Break 1 [58]> (+ 1 2 3) 6 Break 1 [58]> (apply '+ '(1 2 3)) 6 Break 1 [58]> (mapcar '1+ '(100 200 300)) (101 201 301) Break 1 [58]> (mapcar '1+ '(100 200 300)) (101 201 301) Break 1 [58]> (mapcar 'car '(100 200 300)) *** - CAR: 100 is not a list The following restarts are available: ABORT :R1 Abort debug loop ABORT :R2 Abort main loop Break 2 [60]> abort Break 1 [58]> (mapcar 'car '((100 120) (200 220 230) (300 230 455))) (100 200 300) Break 1 [58]> (maplist 'car '((100 120) (200 220 230) (300 230 455))) ((100 120) (200 220 230) (300 230 455)) Break 1 [58]> (maplist 'car '((100 120 200 220 230 300 230 455)) ) ((100 120 200 220 230 300 230 455)) Break 1 [58]> (maplist 'car '(100 120 200 220 230 300 230 455))) (100 120 200 220 230 300 230 455) Break 1 [58]> *** - READ from # # #> # #>>> : an object cannot start with #\) The following restarts are available: ABORT :R1 Abort debug loop ABORT :R2 Abort main loop Break 2 [61]> abort Break 1 [58]> (defun paint (obj color) (setf (get object 'itscolor) color)) PAINT Break 1 [58]> (paint 'sky 'blue) *** - LET*: variable OBJECT has no value The following restarts are available: USE-VALUE :R1 Input a value to be used instead of OBJECT. STORE-VALUE :R2 Input a new value for OBJECT. ABORT :R3 Abort debug loop ABORT :R4 Abort main loop Break 2 [62]> abort Break 1 [58]> (defun paint (obj color) (setf (get obj 'itscolor) color)) PAINT Break 1 [58]> (paint 'sky 'blue) BLUE Break 1 [58]> (paint 'grass 'green) GREEN Break 1 [58]> (mapcar 'paint '(barn house tree) '(brown red green)) (BROWN RED GREEN) Break 1 [58]> (get 'barn 'itscolor) BROWN Break 1 [58]> (get 'tree 'itscolor) GREEN Break 1 [58]> (defun getclolor (obj) (get obj 'itscolor)) GETCLOLOR Break 1 [58]> (mapcar 'getcolor '(sky barn tree)) *** - FUNCALL: undefined function GETCOLOR The following restarts are available: USE-VALUE :R1 Input a value to be used instead of (FDEFINITION 'GETCOLOR). RETRY :R2 Retry STORE-VALUE :R3 Input a new value for (FDEFINITION 'GETCOLOR). ABORT :R4 Abort debug loop ABORT :R5 Abort main loop Break 2 [63]> abort Break 1 [58]> (defun getcolor (obj) (get obj 'itscolor)) GETCOLOR Break 1 [58]> (mapcar 'getcolor '(sky barn tree)) (BLUE BROWN GREEN) Break 1 [58]> (mapcar 'atom '(a b nil (c d) e (cons a b))) (T T T NIL T NIL) Break 1 [58]> abort [64]> (mapcar 'listp '(a b nil (c d) e (cons a b))) (NIL NIL T T NIL T) [65]> (defun testforsth (inp pred) (mapcar pred inp)) TESTFORSTH [66]> (testfor '(a b nil (c d) e (cons a b)) 'listp) *** - EVAL: undefined function TESTFOR The following restarts are available: USE-VALUE :R1 Input a value to be used instead of (FDEFINITION 'TESTFOR). RETRY :R2 Retry STORE-VALUE :R3 Input a new value for (FDEFINITION 'TESTFOR). ABORT :R4 Abort main loop Break 1 [67]> abort [68]> (testforsth '(a b nil (c d) e (cons a b)) 'listp) (NIL NIL T T NIL T) [69]> (defun testforsth (ls fn) (mapcar fn ls)) TESTFORSTH [70]> (testforsth '(a b nil (c d) e (cons a b)) ') *** - READ from # # #> # #>>> : an object cannot start with #\) The following restarts are available: ABORT :R1 Abort main loop Break 1 [71]> abort [72]> (testforsth '(a b nil (c d) e (cons a b)) 'atom) (T T T NIL T NIL) [73]> (testforsth '(a b nil (c d) e (cons a b)) 'number) *** - FUNCALL: undefined function NUMBER The following restarts are available: USE-VALUE :R1 Input a value to be used instead of (FDEFINITION 'NUMBER). RETRY :R2 Retry STORE-VALUE :R3 Input a new value for (FDEFINITION 'NUMBER). ABORT :R4 Abort main loop Break 1 [74]> abort [75]> (testforsth '(a b nil (c d) e (cons a b)) 'numberp) (NIL NIL NIL NIL NIL NIL) [76]> (mapcar 'cons '(a b c) '(1 2 3)) ((A . 1) (B . 2) (C . 3)) [77]> (maplist 'cons '(a b c) '(1 2 3)) (((A B C) 1 2 3) ((B C) 2 3) ((C) 3)) [78]> (defun avg3 (ls) (cond ((null ls) 0) ((equals 1 (length ls)) (car ls)) ) ) AVG3 [79]> (avg3 nil) 0 [80]> (avg3 '(3)) *** - EVAL: undefined function EQUALS The following restarts are available: USE-VALUE :R1 Input a value to be used instead of (FDEFINITION 'EQUALS). RETRY :R2 Retry STORE-VALUE :R3 Input a new value for (FDEFINITION 'EQUALS). ABORT :R4 Abort main loop Break 1 [81]> abort [82]> abort *** - SYSTEM::READ-EVAL-PRINT: variable ABORT has no value The following restarts are available: USE-VALUE :R1 Input a value to be used instead of ABORT. STORE-VALUE :R2 Input a new value for ABORT. ABORT :R3 Abort main loop Break 1 [83]> abort [84]> (defun avg3 (ls)(defun avg3 (ls) (cond ((null ls) 0) ((equals 1 (length ls)) (car ls)) ) ) (cond ((null ls) 0) ((equal 1 (length ls)) (car ls)) ) ) AVG3 [85]> (avg3 '(3)) 3 [86]> (defun avg3 (ls) (cond ((null ls) 0) ((equal 1 (length ls)) (car ls)) ((equal 2 (length ls)) (/ (+ (car ls) (cadr ls)) 2)) ) ) AVG3 [87]> (avg '( 2 3)) *** - EVAL: undefined function AVG The following restarts are available: USE-VALUE :R1 Input a value to be used instead of (FDEFINITION 'AVG). RETRY :R2 Retry STORE-VALUE :R3 Input a new value for (FDEFINITION 'AVG). ABORT :R4 Abort main loop Break 1 [88]> abort [89]> (avg3 '( 2 3)) 5/2 [90]> (defun avg3 (ls) (cond ((null ls) 0) ((equal 1 (length ls)) (car ls)) ((equal 2 (length ls)) (/ (+ (car ls) (cadr ls)) 2)) (t (/ (+ (car ls) (cadr ls) (caddr ls)) 3)) ) ) AVG3 [91]> (avg3 '( 2 3 4)) 3 [92]> (avg3 '( 2 3 4 5 6 7)) 3 [93]> (maplist 'avg3 '( 2 3 4 5 6 7)) (3 4 5 6 13/2 7) [94]> (maplist 'avg3 '( 2 6 3 4 5 6 7)) (11/3 13/3 4 5 6 13/2 7) [95]> nil NIL [96]> (defun aa (x y) (* x y )) AA [97]> (aa 5 6) 30 [98]> (setq aa 9) 9 [99]> aa 9 [100]> (aa 5 6) 30 [101]> (describe 'aa) AA is the symbol AA, lies in #, is accessible in 1 package COMMON-LISP-USER, a variable, value: 9, names a function, has 1 property SYSTEM::DEFINITION. For more information, evaluate (SYMBOL-PLIST 'AA). # is the package named COMMON-LISP-USER. It has 2 nicknames CL-USER, USER. It imports the external symbols of 2 packages COMMON-LISP, EXT and exports no symbols, but no package uses these exports. 9 is an integer, uses 4 bits, is represented as a fixnum. # is an interpreted function. Argument list: (X Y) [102]> (defun bb (x y) (* x y )) BB [103]> (sum-loop 'func2 6) 92 [104]> (sum-loop '(lambda (x) (+ 2 (* x x))) 6) *** - APPLY: argument (LAMBDA (X) (+ 2 (* X X))) is not a function. To get a function in the current environment, write (FUNCTION ...). To get a function in the global environment, write (COERCE '... 'FUNCTION). The following restarts are available: ABORT :R1 Abort main loop Break 1 [105]> abort [106]> (sum-loop #'(lambda (x) (+ 2 (* x x))) 6) 104 [107]> (sum-loop (function (lambda (x) (+ 2 (* x x)))) 6) 104 [108]> (sum-loop #'(lambda (x) (+ 2 (* x x))) 6) 104 [109]> (sum-loop #'(lambda (x) (+ 2 (* x x x))) 6) 454 [110]> (sum-loop #'(lambda (x) (+ 2 (* x x x x))) 6) 2288 [111]> (defun bb (x y) (* x y )) BB [112]> (describe 'bb) BB is the symbol BB, lies in #, is accessible in 1 package COMMON-LISP-USER, names a function, has 1 property SYSTEM::DEFINITION. For more information, evaluate (SYMBOL-PLIST 'BB). # is the package named COMMON-LISP-USER. It has 2 nicknames CL-USER, USER. It imports the external symbols of 2 packages COMMON-LISP, EXT and exports no symbols, but no package uses these exports. # is an interpreted function. Argument list: (X Y) [113]> (symbol-function 'bb) # [114]> bb *** - SYSTEM::READ-EVAL-PRINT: variable BB has no value The following restarts are available: USE-VALUE :R1 Input a value to be used instead of BB. STORE-VALUE :R2 Input a new value for BB. ABORT :R3 Abort main loop Break 1 [115]> abort [116]> (setq bb 2) 2 [117]> bb 2 [118]> (symbol-function 'bb) # [119]> (setf (symbol-function 'bb) '(lambda (w) (+ 2 w))) *** - SYSTEM::%PUTD: argument (LAMBDA (W) (+ 2 W)) is not a function. To get a function in the current environment, write (FUNCTION ...). To get a function in the global environment, write (COERCE '... 'FUNCTION). The following restarts are available: ABORT :R1 Abort main loop Break 1 [120]> abort [121]> (setf (symbol-function 'bb) #'(lambda (w) (+ 2 w))) # [122]> (bb 3 4) *** - EVAL/APPLY: too many arguments given to :LAMBDA The following restarts are available: ABORT :R1 Abort main loop Break 1 [123]> abort [124]> (bb 3) 5 [125]> (bb 4) 6 [126]> (sqrt 4) 2 [127]> (sum-loop 'func2 5) 56 [128]> (sum-loop 'sqrt 5) 9.382333 [129]> (sum-loop #'(lambda (x) (* x (1+ x) (1- x))) 5) 211 [130]> (sum-loop (function (lambda (x) (* x (1+ x) (1- x)))) 5) 211 [131]> (sum-loop '(lambda (x) (* x (1+ x) (1- x))) 5) *** - APPLY: argument (LAMBDA (X) (* X (1+ X) (1- X))) is not a function. To get a function in the current environment, write (FUNCTION ...). To get a function in the global environment, write (COERCE '... 'FUNCTION). The following restarts are available: ABORT :R1 Abort main loop Break 1 [132]> abort [133]> (dribble) 2009-06-24 21:01:37 ;; Dribble of # finished on NIL.