ࡱ>  {Root Entry Fm A@1Table WWordDocumentSummaryInformation(?  3459J;<=>?y:KLUNOPQRSTkVWXYZ[\]^_`abcdefgslmnopqrtuvwxz}~DocumentSummaryInformation8:CompObjXObjectPool0Table_Root Entry FF9A@1Table%WordDocument$DSummaryInformation(? !#6&'()*+,-./01278@;<=>? B:CDEFGHIhNOPQRSTkijMlmnopqr"DocumentSummaryInformation8:CompObjXObjectPool0Table_ i4@4 NormalCJ_HmH sH tH <A@< Default Paragraph Font.0!z!z!z!z z zb.  stw|,OPUVc&'<=EFWXv*HI\mv,-GHo2?N`op=>Tqr ,-0!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!;<=>@ABCD i4@4 NormalCJ_HmH sH tH <A@< Default Paragraph Font'0!z!z!z!z z z z z z z z z z z z z z zi 6  vBD/!$''  ( 9 4  . 'EJbcjrv,-9:JKOTgz{~3VW\]j  -.CDLM^_}  1OPct}$%34NOv$%9FUgvwDE[xy34=>XYgt   + R : \ z   ] N f g    Y Z r {  Aef78t9l:;QR K|}+,Pta6hi{Krs /ZGHTYZ3@ST=>idegh?@ABrs 4_'@OWXp HIk* + A \ h i  !!*!+!,!-!L!M!d!x!!!!!!!!)"@"M""""""""##B#C#_#k#########$$5$j$$$$$$$% % %,%O%^%%%%%%%%%&&(&)&S&T&v&&&''':']'''''''''!!!!!!!!!!!!!!!!!!!!!!#!#!#!#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!u!!!!!!!!!!!!!!!!!!!u!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!u!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!(!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!2?N`op=>Tqr ,-0000000000000000000000000000000000000000000000B H git069B  iv UnknownDoug M,,0,,0Doug M%NO NAME:AIP new:08:classes:03:3. 5-6g0@h}{SC$Eƀ5b' &';<=DEFGHVWox*I,-6>F|JLWfoNOPVYklm+,-.0 @0@0:00H00J00t00v00@0x0000@0 @0.@041P@04041404041414140840:40j41|404040L@0x@0z@0|@0T50V5060F6060l50@1 70@0"70$70J70T7070808081 81281B80R8080@0@0.91090\90@1^90@0@0`91 :0:0&:0D:0V:0@1.A10A02A1>A1DA1hA1jA0lA1A0:0:0A0:0$@0$@GTimes New Roman5Symbol3 Arial9New York7Courier3Times"1h &[ɆIT$xx0@5Doug MDoug M@5Doug MDoug M ՜.+,0 hp|  'SIS$ 5 Title Oh+'0P    $08@H'5ssDoug MfougNormalfDoug Mf16gMicrosoft Word 10.0@6@Fͩ @ ޭ)IT$$%%:::::::::::::::::::::::::::::::::::::function defined in scope of lexical variable, can continue to refer to that variable even if returned outside scope of the variable (setf fn (let ((i 3)) (# (lambda (x) (+ x i)))) free variable- outside the function definitionclosures can share variables (let ((counter 0)) (defun reset () (setf counter o)) (defun stamp () (setf counter (+ counter 1))))@ vjbjbD.l6t l \, D i4@4 NormalCJ_HmH sH tH <A@< Default Paragraph Font(0!z!z!z!z z zb'(  stw|,OPUVc $%45JKSTef  8VWj{+,:;UV}+,@M\n}~%&'*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!45JKSTef  8VWj{+,:;UV}+,@M\n}~&'*000000000000000000000000000000000000000000000000000000000000000000000000000000000: H git069:  iv UnknownDoug M:*:*Doug M%NO NAME:AIP new:08:classes:03:3. 5-6g*@h}{SC$Eƀ5b' #$%45IJKRSTUVde}  8W+,:;DLTXZet}&'(0 @100800@0:00H00J00t00v00@0x0000@0 @0.@041P@04041404041414140840:40j41|404040L@0x@0z@0|@0T50V5060F6060l50@1 70@0"70$70J70T7070808081 81281B80R8080@0@0.91090\90@1^90@0@0`91 :0:0&:0D:0V:0:0:0:0:0@0$@0$@GTimes New Roman5Symbol3 Arial9New York7Courier3Times"1h &ZɆuB $xx0t@5Doug MDoug M!!6!!(!!!!!!!!!!!!!!!!!!u!!6!6!!!!!6!6!!!!!!!!!!!O!!!!!!!!u!u!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!u!!!!!!!!!!!!!!!u!u!u!u!!!!!!!!!!!!!!>$>>>F>@@>`>r P F _>_>5. Control 5.1 Blocks (progn for side effects only . ) value returned (block . (return-from ) ..) anonymous block named nil (return ) (dolist (x '(a b c d e)) (format t "~A " x) (if (eql x 'c) (return 'done))) 5.2 Context lexical context let let* destructuring-bind 5.3 Conditionals if when unless cond (cond (*)* ) (cond (*) .. (t *)) (defun our-member (obj lst) (cond (!!!!!!!!!!!!!!!!!!!!!u!!!!!!!!!!!!!!!!!!!!!! 23JKXYxy!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!000v H giv  iv MZ  "%'*=@BEFI^a"%?BEH]beiy3:DGHKMZtvw{|/0PTX\gl:::::::::::::::::::::::::::::::::::::Doug M%NO NAME:AIP new:08:classes:03:3. 5-6g@h}{S@0 @0@0 @0$@0$@GTimes New Roman5Symbol3 Arial9New York7Courier3Times"1h &ZɆ M $xx0(atom lst) nil) ((eql (car lst) obj) lst) (t (our-member obj (cdr lst))))) case (case (| *)*) typecase uses typep instead of eql 5.4 Iteration <<<< Functions and Special Forms for Repetition 57 dolist loop over elements of a list dotimes loop over successive integers do, do* general loop, sparse syntax loop general loop, verbose syntax mapc, mapcar loop over elements of list(s) some, every loop over list until condition find, reduce etc. more FMicrosoft Word DocumentNB6WWord.Document.8 i4@4 NormalCJ_HmH sH tH <A@< Default Paragraph Font0!z!z!z!zb stw|,OPUVc specific looping functions recursion general repetion versions of length using these: (dolist (variable list optional-result) body...) (defun length1 (list) (let ((len 0)) (dolist (element list) (incf len)) len)) (defun length1.1 (list) (let ((len 0)) (dolist (element list len) (incf len)))) (defun length2 (list) (let ((len 0)) (mapc #'(lambda (element) (incf len)) list) len)) (dotimes (variable number optional-result) body...) (do ((variable initial next)...) (exit-test result) body...) (defun length3 (list) (do ((len 0 (+ len 1)) (l list (rest l))) ((null l) len)) unspecific- re iteration, variable for elements of list, (defun length4 (list) (loop for element in list count t)) (defun length5 (list) (loop for element in list summing 1)) (defun length (list) (loop with len = 0 until (null list) for element = (pop list) do (incf len) finally (return len))) 5.5 Multiple Values 5.6 Aborts 5.7 Example: Date Arithmetic 6. Functions 6.1 Global Functions 6.2 Local Functions 6.3 Parameter Lists 6.4 Example: Utilities 6.5 Closures 6.6 Example: Function Builders 6.7 Dynamic Scope 6.8 Compilation 6.9 Using Recursion 7. I/O 7.1 Streams 7.2 Input 7.3 Output 7.4 Example: String Substitution 7.5 Macro Characters 8. Symbols 8.1 Symbol Names 8.2 Property Lists 8.3 Symbols are Big 8.4 Creating Symbols 8.5 Multiple Packages 8.6 Keywords 8.7 Symbols and Variables 8.8 Example: Random Test 9. Numbers 9.1 Types 9.2 Conversion and Extraction 9.3 Comparison 9.4 Arithmetic 9.5 Exponentiation 9.6 Trigonnometric Functions 9.7 Representation 9.8 Example: Ray-Tracing 10. Macros 10.1 Eval 10.2 Macros 10.3 Backquote 10.4 Example: Quicksort 10.5 Macro Design 10.6 Generalized Reference 10.7 Macro Utilities 10.8 11. CLOS 11.1 Object-Oriented Programming 11.2 Classes and Instances 11.3 Slot Properties 11.4 Superclasses 11.5 Precedence 11.6 Generic Functions 11.7 Auxiliary Methods 11.8 Method Combination 11.9 Encapsulation 11.10 Two Models 12. Structure 12.1 Shared Structure 13. Speed    &2as % c  &v:0044n5 7"7^9`9:B6 5B*ph5 CJOJQJOJQJ 5OJQJ/   >C[\cko %&23CDH   >C[\cko %&23CDHM`astw|,OPUVc# J o  8 9 Y Z ( 9 : P ` | e!!!!!!!!!!!!!!!!!!!!!!!  -.CDLM^_}  1OPct}$%34NOv$%9FUgvwDE[xy345=>XYgt   + R : \ z   ] N f g     Y Z r {  Aef78tu9l:;QR K|}+,Pta6hi{Krs /ZGHTYZ3@AST=>idegh?@ABCrs 4_   / G c y z $ 2 3 H \ p &'(=>RSgh45JKVWhie $ 2 3 H \ p  &'(=>RSggh45JKVWhii|} 78GHWXkl34IJOPYZ{|./@AOPfghijtuvRi|} 78GHWXkl34IJOPYZ{|./@AOPfghijtuv:0H0J0t0`'@OWXp HIk* + A \ h i  !!*!+!,!-!.!L!M!d!x!!!!!!!!)"@"M""""""""##B#C#_#k##########$$5$j$$$$$$$% % %,%O%^%%%%%%%%%&&(&)&S&T&v&&&'''':']'''''''''0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@000@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@00@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@00@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@00@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@00@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@00@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@0@00JVld FKH git069BGZNTN[`vepjDp(twz|Ld BCDEGHIJLMNOP iv UnknownDoug M OLE_LINK12 OLE_LINK1 OLE_LINK2 OLE_LINK3 OLE_LINK4 OLE_LINK5 OLE_LINK6 OLE_LINK7 OLE_LINK8 OLE_LINK9 OLE_LINK10 OLE_LINK11N! %,%Q%%T&T&'''''' !+%N%%%''''''''N%N%'N%N%'Doug M%NO NAME:AIP new:08:classes:03:3. 5-6g'@N%N%h}N%N%{SC$Eƀ5b' 5OJQJPHM`astw|,OPUVc ^`# J o  8 9 Y Z  ( 9 : P ` |   / G c y z / =!"#$%5.4 Iteration values multiple-values-bind catch throw unwind-protectt0v0x000044444:4<4x444444(5V5f5h5l5n5F6666` fboundp symbol-function (setf (symbol-function  add2) # (lambda (x) (+ x 2))) (defun primo (lst) (car lst)) (defun (setf primo) (val lst) (setf (car lst) val)) labels functions can refer to each other so can be used recursively (labls ((len (lst) (if (null lst) 0 (+ (len (cdr lst)) 1 )))) &rest &optional &key (defun keylist (a &key x y z) (list a x y z)) (leylist 1 :y 2) => ( 1 NIL 2 NIL) with defaults can pass keyword argument (defun our-adjoin (obj lst &rest args) (if (apply # member obj lst args) lst (cons obj lst))) bottom up programming function returned as value of expression (defun combiner (x) (typecase x (number # +) (list # append) (t # list))) (defun combine (&rest args) (apply (combiner (car args)) args)) 666 7$727H7T7V77777888 8T8V8888,9.909^999999:8:V:X::::::::::::::@ AA:AtAvABB6BXBBB-.BCDKLMNO]^v1P$%34=EMQS^mvUVW]`rst2346<=>   tv@BAD4@* + *!/!#$$$,%.%/%2%M%N%%%%(&T&v&x&y&|&&&&''''':'<'='@'['\']'`'a'e''''''''''''''''''1D0 D0 @0@0:00H00J00t00v00@0x0000@0 @0.@041P@04041404041414140840:40j41|404040L@0x@0z@0|@0T50V5060F6060l50@1 70@0"70$70J70T7070808081 81281B80R8080@0@0.91090\90@1^90@0@0`91 :0:0&:0D:0V:0@1.A10A02A1>A1DA1hA1jA0lA1A0:0:0A0:0$@0D1D0D0 D0"D1F0F1G0G0,G00G1M0M1N0N0N0R0R1Z0Z1`0`1a1a0a0&f0*f0(l0.l1n0&n1r0r0s0s0u0v0{0{0{0{1}1~1~1 ~1@~0B~1~0~0`00N11111Ԁ0ր0؀10100ց111 1&1\0^1`1f1h0p101Ă011011,1.0:1<1P1T0b0$@GTimes New Roman5Symbol3 Arial9New York7Courier3Times"1h &*[Ɇx!G$xx0)@5Doug MDoug M@5Doug MDoug M ՜.+,0 hp|  'SISG)$ 5 Title Oh+'0P    $08@H'5ssDoug MfougNormalfDoug Mf17gMicrosoft Word 10.0@@Fͩ @ #S(NAME :FIRST BARNEY :LAST RUBBLE) > (name-first b) => Barney > (name-middle b) => NIL > (name-last b) => RUBBLE > (name-p b) => T > (name-p 'Barney) => NIL > (setf (name-middle b) 'Q) => Q > (b => #S(NAME :FIRST BARNEY :MIDDLE Q :LAST RUBBLE) implemented as vectors, access any element in one operation Special Forms for Conditionals conditional if form cond form (when test a b c) (if test (progn a b c)) (cond (test a b c)) (unless test x y) (if (not test) (progn x y)) (cond ((not test) x y) (and a b c) (if a (if b c)) (cond (a (cond (b c))) (or a b c) (if a a (if b b c)) (cond (a)(b)(c)) (case a (b c) (t x)) (if (eql a 'b) c x) (cond ((eql a 'b) c) (t x) or, case, cond evaluate expressions only once, if translations may eval more than once- preferences for uses: 1. don't use and and or for anything other than testing logical conditions, for control use when, unless, if (and (> n 100)(princ "N is large.")) ; poor style (or (<= n 100)(princ "N is large.")) ;worse (cond ((> n 100)(princ "N is large.")) ;ok (when (> n 100)(princ "N is large."")) ;better 2. to return value rather than take action use cond and if (with explicit nil in the else case) rather than when and unless, (which implicitly return nil in the else case). 3. one possibility: when, unless two possibilities: if, (cond) three+ possibilities: cond 4. several tests comparing expression to constants: case (case expression (match result ....) .....) ;if match is list, check against each element ; if match is t or otherwise then matches anything (case x (cond (1 10) ((eql x 1) 10) (2 20)) ((eql x 2) 20)) (typecase x (cond (number (abs x)) ((typep x 'number) (abs x)) (list (length))) ((typep x 'list) (length x))) (ecase x (cond (1 10) ((eql x 1) 10) (2 20)) ((eql x 2) 20) (t (error "no valid case"))) (etypecase x (cond (number (abs x)) ((typep x 'number) (abs x)) (list (length x))) ((typep x 'list) (length x)) (t (error "no valid typecase"))) ccase and ctypecase -> continuable errors Special Forms for Dealing with Variables and Places setf ;;Lisp /* Pascal */ (setf x 0) x := o; (setf (aref A i j) 0) A[i, j] := 0; (setf (rest list) nil) list^.ret := nil; (setf (name-middle b) 'Q) b^.middle := "Q"; variable, components of structure, defsetf & define-setf-method extend expressions allowed rplacd: (rplacd list nil) ( (setf (rest list) nil) functional style and variable introduction: parameters let (let ((variable value)...) (let ((x 40) (y (+1 1))) body...) (+ x y)) ((lambda (variable...) ((lambda (x y) body...) (+ x y) value...) 40 (+ 1 1)) let* (let* ((x 6) (y (* x x))) (+ x y)) lists as stacks: (push x list) ( (setf list (cons x list)) (pop list) ( (let ((result (first list))) (setf list (rest list)) result) running sums: (incf x) ( (incf x 1) ( (setf x (+ x 1)) (decf x) ( (decf x 1) ( (setf x (- x 1)) complex structure locations (vs variables) Lisp evaluates any subform not more than once (defstruct player (score 0) (wins 0)) (defun determine-winner (players) "Increment the WINS for the player with the highest score." (incf (player-wins (first (sort players #'> :key #'player-score))))) ( (defun determine-winner (players) "Increment the WINS for the player with the highest score." (let ((temp (first (sort players #'> :key #'player-score)))) (setf (player-wins temp) (+ (player-wins temp) 1 )))) Functions and Special Forms for Repetition dolist loop over elements of a list dotimes loop over successive integers do, do* general loop, sparse syntax loop general loop, verbose syntax mapc, mapcar loop over elements of list(s) some, every loop over list until condition find, reduce etc. more specific looping functions recursion general repetion versions of length using these: (dolist (variable list optional-result) body...) (defun length1 (list) (let ((len 0)) (dolist (element list) (incf len)) len)) (defun length1.1 (list) (let ((len 0)) (dolist (element list len) (incf len)))) (defun length2 (list) (let ((len 0)) (mapc #'(lambda (element) (incf len)) list) len)) (dotimes (variable number optional-result) body...) (do ((variable initial next)...) (exit-test result) body...) (defun length3 (list) (do ((len 0 (+ len 1)) (l list (rest l))) ((null l) len)) unspecific- re iteration, variable for elements of list, (defun length4 (list) (loop for element in list count t)) (defun length5 (list) (loop for element in list summing 1)) (defun length (list) (loop with len = 0 until (null list) for element = (pop list) do (incf len) finally (return len))) Repetition through Recursion (defun length9 (list) (if (null list) 0 ( + 1 (length9 (rest list))))) aux functions: (tail recursion) (defun length10 (list) (length10-aux list 0)) (defun length10-aux (sublist len-so-far) (if (null sublist) len-so-far (length10-aux (rest sublist) (+ 1 len-so-far)))) using optional argument defun length11 (list &optional (len-so-far 0)) (if (null list) len-so-far (length11 (rest list) (+ 1 len-so-far)))) using lables to create local function (defun labels12 (the-list) (labels ((length13 (list len-so-far) (if (null list) len-so-far (length13 (rest list) (+ 1 len-so-far))))) (length13 the-list 0))) Macros 1. decide if necessary (sceptical view& .) 2. write syntax of macro (keep it natural, simple) 3. figure out the expansion code 4. use defmacro to implement syntax/expansion correspondance (while test body) (loop (unless test (return nil)) body) (defmacro while (test &rest body) "repeat body while test is true" (list* `loop (list `unless test `(return nil)) body )) (macroexpand-1 `(while (< I 10) (print (* i i) (setf i (+ i 1)))) => (LOOP (UNLESS (< I 10) (RETURN NIL)) (PRINT (* I I)) (SETF I (+ I 1))) substituting into a template of expansion (defmacro while (test &rest body) "repeat body while test is true" (let ((code `(loop (unless test (return nil)) . body))) (subst test `test (subst body `body code)))) backquote notation (defmacro while (test &rest body) "repeat body while test is true" `(loop (unless ,test (return nil)) ,@body)) (setf test1 `(a test)) `(this is ,test1) `(this is ,@test1) `(this is . ,test1) B DDD D"DVDXDtDDDE:ETEEEEEEJFFFF,G.GGGG |]| x0]0GH^HHH$I^IIIII`JJJ>K@KKBLrLtLL4M6MMMMMXNZN |]| xZNNNNNNONOOO(PpPrPPPQ2QfQQRRRRRRSST ]  P0]0T~TThUjUVVHVJV$W&WWW*OJQJ 6OJQJOJQJ 5OJQJ5B*OJQJph%DpTpVppppqq0qPqqqqqq6r8r|rrrrr sXsssss(t`(t^tvtxttttt"uJuruuuuuuvv>v@vnvvvvv@wBwrww0]0ww&x@xxxxx>yfyyyy*z,zdz|zzz{d{{{{{{{{|z|0]0z||>}@}d}f}r}}}}}D~b~~~~*Z`bLN؀L0]0Lԁց`‚Ă<d0]0 @ vjbjb'l&GGGGG!+T\HHHHHHIdJ4JJJJJJJ,U WDK LJHHLJLJKxJHHH$xJxJxJLJHHJxJnLJJxJ`xJJJxH!n&GbJJJ +T+TJWxJWJxJ5. Control 5.1 Blocks (progn for side effects only . ) value returned (block . (return-from ) ..) anonymous block named nil (return ) (dolist (x '(a b c d e)) (format t "~A " x) (if (eql x 'c) (return 'done))) 5.2 Context lexical context let let* destructuring-bind 5.3 Conditionals if when unless cond (cond (*)* ) (cond (*) .. (t *)) (defun our-member (obj lst) (cond ((atom lst) nil) ((eql (car lst) obj) lst) (t (our-member obj (cdr lst))))) case (case (| *)*) typecase uses typep instead of eql 5.4 Iteration <<<< Functions and Special Forms for Repetition 57 dolist loop over elements of a list dotimes loop over successive integers do, do* general loop, sparse syntax loop general loop, verbose syntax mapc, mapcar loop over elements of list(s) some, every loop over list until condition find, reduce etc. more specific looping functions recursion general repetion versions of length using these: (dolist (variable list optional-result) body...) (defun length1 (list) (let ((len 0)) (dolist (element list) (incf len)) len)) (defun length1.1 (list) (let ((len 0)) (dolist (element list len) (incf len)))) (defun length2 (list) (let ((len 0)) (mapc #'(lambda (element) (incf len)) list) len)) (dotimes (variable number optional-result) body...) (do ((variable initial next)...) (exit-test result) body...) (defun length3 (list) (do ((len 0 (+ len 1)) (l list (rest l))) ((null l) len)) unspecific- re iteration, variable for elements of list, (defun length4 (list) (loop for element in list count t)) (defun length5 (list) (loop for element in list summing 1)) (defun length (list) (loop with len = 0 until (null list) for element = (pop list) do (incf len) finally (return len))) 5.5 Multiple Values 5.6 Aborts 5.7 Example: Date Arithmetic 6. Functions 6.1 Global Functions 6.2 Local Functions 6.3 Parameter Lists 6.4 Example: Utilities 6.5 Closures 6.6 Example: Function Builders 6.7 Dynamic Scope 6.8 Compilation 6.9 Using Recursion 7. I/O 7.1 Streams 7.2 Input 7.3 Output 7.4 Example: String Substitution 7.5 Macro Characters 8. Symbols 8.1 Symbol Names 8.2 Property Lists 8.3 Symbols are Big 8.4 Creating Symbols 8.5 Multiple Packages 8.6 Keywords 8.7 Symbols and Variables 8.8 Example: Random Test 9. Numbers 9.1 Types 9.2 Conversion and Extraction 9.3 Comparison 9.4 Arithmetic 9.5 Exponentiation 9.6 Trigonnometric Functions 9.7 Representation 9.8 Example: Ray-Tracing 10. Macros 10.1 Eval 10.2 Macros 10.3 Backquote 10.4 Example: Quicksort 10.5 Macro Design 10.6 Generalized Reference 10.7 Macro Utilities 10.8 11. CLOS 11.1 Object-Oriented Programming 11.2 Classes and Instances 11.3 Slot Properties 11.4 Superclasses 11.5 Precedence 11.6 Generic Functions 11.7 Auxiliary Methods 11.8 Method Combination 11.9 Encapsulation 11.10 Two Models 12. Structure 12.1 Shared Structure 13. Speed    &2as % c  &v:0044n5 7"7^9`9:BDD D"D,G0GGGIII\JtJJJ>KPKKKKLLLMPMMMMMMTNRRRSVJV>* >*OJQJ 6OJQJ6 5B*ph5 CJOJQJOJQJ 5OJQJT   >C[\cko %&23CDH   >C[\cko %&23CDHM`astw|,OPUVc# J o  8 9 Y Z ( 9 : P ` | eHM`astw|,OPUVc ^`# J o  8 9 Y Z  ( 9 : P ` |   / G c y z function defined in scope of lexical variable, can continue to refer to that variable even if returned outside scope of the variable (setf fn (let ((i 3)) (# (lambda (x) (+ x i)))) free variable- outside the function definitionclosures can share variables (let ((counter 0)) (defun reset () (setf counter o)) (defun stamp () (setf counter (+ counter 1))))