SlideShare a Scribd company logo
1 of 52
Download to read offline
Quick Reference




cl              Common


lisp
Bert Burgemeister
Common Lisp Quick Reference


Contents
1     Numbers                                   3         9.5   Control Flow . . . 19
      1.1 Predicates . . .            .         3         9.6   Iteration . . . . 20
      1.2 Numeric Functns             .         3         9.7   Loop Facility . . . 21
      1.3 Logic Functions             .         4
                                                    10 CLOS                    23
      1.4 Integer Functions           .         5
                                                       10.1 Classes . . . . . 23
      1.5 Implementation-
                                                       10.2 Generic Functns . 25
          Dependent . . .             .         6
                                                       10.3 Method Combi-
2     Characters                                6           nation Types . . . 26
3     Strings                                   7   11 Conditions and Errors         27
4     Conses                                    8   12 Types and Classes             29
      4.1 Predicates . . .            .         8
      4.2 Lists . . . . .             .         8   13 Input/Output                  31
      4.3 Association Lists           .         9      13.1 Predicates . . .     .   31
      4.4 Trees . . . . .             .        10      13.2 Reader . . . .       .   31
      4.5 Sets . . . . .              .        10      13.3 Character Syntax     .   33
                                                       13.4 Printer . . . .      .   34
5     Arrays                 10                        13.5 Format . . . .       .   36
      5.1 Predicates . . . . 10                        13.6 Streams . . . .      .   38
      5.2 Array Functions . 10                         13.7 Paths and Files .    .   40
      5.3 Vector Functions . 11
                                                    14 Packages and Symbols          41
6     Sequences               12
                                                       14.1 Predicates . . .     .   41
      6.1 Seq. Predicates . . 12                       14.2 Packages . . .       .   41
      6.2 Seq. Functions . . 12                        14.3 Symbols . . . .      .   43
7     Hash Tables                              14      14.4 Std Packages .       .   43
8     Structures                               15   15 Compiler                      43
                                                       15.1 Predicates . . .     .   43
9     Control Structure                        15
                                                       15.2 Compilation . .      .   43
      9.1 Predicates .        .   .   .        15
                                                       15.3 REPL & Debug         .   45
      9.2 Variables .         .   .   .        16
                                                       15.4 Declarations . .     .   46
      9.3 Functions .         .   .   .        16
      9.4 Macros . .          .   .   .        18   16 External Environment          46




Typographic Conventions
             Fu       M     sO            gF        var         co
name; name; name; name; name; ∗name∗; name
       ⊲ Symbol defined in Common Lisp; esp. function, macro,
       special operator, generic function, variable, constant.

them                      ⊲ Placeholder for actual code.

me                        ⊲ Literal text.

[foo bar ]                ⊲ Either one foo or nothing; defaults to bar.

foo ∗ ; {foo}∗            ⊲ Zero or more foos.

foo + ; {foo}+            ⊲ One or more foos.

foos              ⊲ English plural denotes a list argument.
               
               foo
{foo bar baz }; bar      ⊲ Either foo, or bar , or baz .
               
                baz

 foo
   bar      ⊲ Anything from none to each of foo, bar , and baz .

   baz

foo                       ⊲ Argument foo is not evaluated.

bar                       ⊲ Argument bar is possibly modified.
     P                                                           sO
foo ∗                     ⊲ foo ∗ is evaluated as in progn; see p. 19.

foo; bar ; baz            ⊲ Primary, secondary, and nth return value.
         2        n

T; NIL                    ⊲ t, or truth in general; and nil or ().




2
Common Lisp Quick Reference


1 Numbers
1.1 Predicates
 Fu
(= number + )
  Fu
(/= number + )
      ⊲ T if all number s, or none, respectively, are equal in value.
 Fu
(> number + )
  Fu
(>= number + )
 Fu
(< number + )
  Fu
(<= number + )
      ⊲ Return T if number s are monotonically decreasing,
      monotonically non-increasing, monotonically increasing, or
      monotonically non-decreasing, respectively.
     Fu
(minusp a)
  Fu
(zerop a)                  ⊲ T if a < 0, a = 0, or a > 0, respectively.
  Fu
(plusp a)
     Fu
(evenp integer )
  Fu                       ⊲ T if integer is even or odd, respectively.
(oddp integer)
     Fu
(numberp foo)
  Fu
(realp foo)
  Fu
(rationalp foo)
  Fu
(floatp foo)                       ⊲ T if foo is of indicated type.
  Fu
(integerp foo)
  Fu
(complexp foo)
  Fu
(random-state-p foo)


1.2 Numeric Functions
 Fu
(+ a 0 ∗ )
 Fu              ⊲ Return        a or      a, respectively.
(∗ a 1 ∗ )
 Fu
(– a b ∗ )
 Fu
(/ a b ∗ )
         ⊲ Return a −    b or a/ b, respectively. Without any bs,
         return −a or 1/a, respectively.
     Fu
(1+ a)
 Fu              ⊲ Return a + 1 or a − 1, respectively.
(1– a)
      M
     incf
(     M    place [delta 1 ])
     decf
          ⊲ Increment or decrement the value of place by delta. Re-
          turn new value.
     Fu
(exp p)
  Fu                       ⊲ Return ep or bp , respectively.
(expt b p)
     Fu
(log a [b e ])             ⊲ Return logb a or, without b, ln a.
     Fu
(sqrt n)             √
  Fu             ⊲       n in complex or natural numbers, respectively.
(isqrt n)
     Fu
(lcm integer ∗ 1 )
  Fu
(gcd integer ∗ )
        ⊲ Least common multiple or greatest common denomina-
        tor, respectively, of integers. (gcd) returns 0.
co
pi        ⊲ long-float approximation of π, Ludolph’s number.
 Fu
(sin a)
  Fu
(cos a)          ⊲ sin a, cos a, or tan a, respectively. (a in radians.)
  Fu
(tan a)
     Fu
(asin a)
  Fu             ⊲ arcsin a or arccos a, respectively, in radians.
(acos a)
     Fu                               a
(atan a [b 1 ])            ⊲ arctan   b
                                          in radians.
     Fu
(sinh a)
  Fu
(cosh a)         ⊲ sinh a, cosh a, or tanh a, respectively.
  Fu
(tanh a)



                                                                           3
Common Lisp Quick Reference
    Fu
(asinh a)
  Fu
(acosh a)                  ⊲ asinh a, acosh a, or atanh a, respectively.
  Fu
(atanh a)
Fu
(cis a)                    ⊲ Return ei a = cos a + i sin a.
    Fu
(conjugate a)              ⊲ Return complex conjugate of a.
    Fu
(max num + )
 Fu                        ⊲ Greatest or least, respectively, of nums.
(min num + )
  Fu      Fu         
 {round Fu
  Fu     fround}     
                      
                     
  {floor ffloor}
(   Fu      Fu          n [d 1 ])
 {ceiling fceiling}
  Fu                 
                      
              Fu     
  {truncate ftruncate}
        ⊲ Return as integer or float, respectively, n/d rounded, or
        rounded towards −∞, +∞, or 0, respectively; and remain-
                                                          2
        der.
          Fu
     mod
(     Fu  n d)
     rem
                     Fu     Fu
         ⊲ Same as floor or truncate, respectively, but return re-
         mainder only.
    Fu
(random limit [state ∗random-state∗ ])
                      var

       ⊲ Return non-negative random number less than limit, and
       of the same type.
    Fu
(make-random-state {state NIL T} NIL )
       ⊲ Copy of random-state object state or of the current ran-
       dom state; or a randomly initialized fresh random state.
    var
∗random-state∗             ⊲ Current random state.
    Fu
(float-sign num-a [num-b 1 ])               ⊲ num-b with num-a’s sign.
    Fu
(signum n)
       ⊲ Number of magnitude 1 representing sign or phase of n.
    Fu
(numerator rational )
  Fu
(denominator rational )
       ⊲ Numerator or denominator, respectively, of rational ’s
       canonical form.
    Fu
(realpart number )
  Fu
(imagpart number )
        ⊲ Real part or imaginary part, respectively, of number .
    Fu
(complex real [imag 0 ])            ⊲ Make a complex number.
    Fu
(phase number )            ⊲ Angle of number ’s polar representation.
    Fu
(abs n)             ⊲ Return |n|.
    Fu
(rational real )
  Fu
(rationalize real )
        ⊲ Convert real to rational. Assume complete/limited accu-
        racy for real .
    Fu
(float real [prototype 0.0F0 ])
        ⊲ Convert real into float with type of prototype.


1.3 Logic Functions
Negative integers are used in two’s complement representation.
    Fu
(boole operation int-a int-b)
        ⊲ Return value of bitwise logical operation . operation s are

               co
               boole-1              ⊲ int-a.
               co
               boole-2              ⊲ int-b.
               co
               boole-c1             ⊲ ¬int-a.
               co
               boole-c2             ⊲ ¬int-b.
               co
               boole-set            ⊲ All bits set.
               co
               boole-clr            ⊲ All bits zero.



4
Common Lisp Quick Reference

          co
          boole-eqv            ⊲ int-a ≡ int-b.
          co
          boole-and            ⊲ int-a ∧ int-b.
          co
          boole-andc1          ⊲ ¬int-a ∧ int-b.
          co
          boole-andc2          ⊲ int-a ∧ ¬int-b.
          co
          boole-nand           ⊲ ¬(int-a ∧ int-b).
          co
          boole-ior            ⊲ int-a ∨ int-b.
          co
          boole-orc1           ⊲ ¬int-a ∨ int-b.
          co
          boole-orc2           ⊲ int-a ∨ ¬int-b.
          co
          boole-xor            ⊲ ¬(int-a ≡ int-b).
          co
          boole-nor            ⊲ ¬(int-a ∨ int-b).
    Fu
(lognot integer )       ⊲ ¬integer .
    Fu
(logeqv   integer ∗ )
  Fu
(logand integer ∗ )
        ⊲ Return value of exclusive-nored or anded integer s, re-
        spectively. Without any integer , return −1.
    Fu
(logandc1 int-a int-b)         ⊲ ¬int-a ∧ int-b.
    Fu
(logandc2 int-a int-b)         ⊲ int-a ∧ ¬int-b.
    Fu
(lognand int-a int-b)          ⊲ ¬(int-a ∧ int-b).
    Fu
(logxor integer ∗ )
  Fu
(logior integer ∗ )
         ⊲ Return value of exclusive-ored or ored integer s, respec-
         tively. Without any integer, return 0.
    Fu
(logorc1 int-a int-b)          ⊲ ¬int-a ∨ int-b.
    Fu
(logorc2 int-a int-b)          ⊲ int-a ∨ ¬int-b.
    Fu
(lognor int-a int-b)           ⊲ ¬(int-a ∨ int-b).
    Fu
(logbitp i integer )
        ⊲ T if zero-indexed ith bit of integer is set.
    Fu
(logtest int-a int-b)
        ⊲ Return T if there is any bit set in int-a which is set in
        int-b as well.
    Fu
(logcount int)
       ⊲ Number of 1 bits in int ≥ 0, number of 0 bits in int < 0.


1.4 Integer Functions
    Fu
(integer-length integer)
        ⊲ Number of bits necessary to represent integer .
    Fu
(ldb-test byte-spec integer )
        ⊲ Return T if any bit specified by byte-spec in integer is set.
    Fu
(ash integer count)
        ⊲ Return copy of integer arithmetically shifted left by
        count adding zeros at the right, or, for count < 0, shifted
        right discarding bits.
    Fu
(ldb byte-spec integer )
        ⊲ Extract byte denoted by byte-spec from integer . setfable.
     Fu
    deposit-field
(    Fu           int-a byte-spec int-b)
    dpb
         ⊲ Return int-b with bits denoted by byte-spec replaced
                                                         Fu
         by corresponding bits of int-a, or by the low (byte-size
         byte-spec) bits of int-a, respectively.
    Fu
(mask-field byte-spec integer)
       ⊲ Return copy of integer with all bits unset but those de-
       noted by byte-spec. setfable.
    Fu
(byte size position )
        ⊲ Byte specifier for a byte of size bits starting at a weight
        of 2position .
    Fu
(byte-size byte-spec)
  Fu
(byte-position byte-spec)
        ⊲ Size or position, respectively, of byte-spec.




                                                                    5
Common Lisp Quick Reference

1.5 Implementation-Dependent
 co          
short-float  
 co          
single-float      epsilon
 co            -
double-float negative-epsilon
             
 co          
long-float
        ⊲ Smallest possible number making a difference when
        added or subtracted, respectively.
 co                       
least-negative             short-float
                          
 co                       
least-negative-normalized    single-float
 co                        -
least-positive             double-float
                          
 co                       
least-positive-normalized    long-float
        ⊲ Available numbers closest to −0 or +0, respectively.
               
               short-float
               
co             single-float
               
most-negative
co            - double-float
most-positive long-float
               
               
                fixnum
       ⊲ Available numbers closest to −∞ or +∞, respectively.
    Fu
(decode-float n)
  Fu
(integer-decode-float n)
        ⊲ Return significand, exponent, and sign of float n.
                               2               3
    Fu
(scale-float n [i ])        ⊲ With n’s radix b, return nbi .
    Fu
(float-radix n)
  Fu
(float-digits n)
  Fu
(float-precision n)
        ⊲ Radix, number of digits in that radix, or precision in that
        radix, respectively, of float n.
    Fu
(upgraded-complex-part-type foo [environment NIL ])
       ⊲ Type of most specialized complex number able to hold
       parts of type foo.



2 Characters
The standard-char type comprises a-z, A-Z, 0-9, Newline, Space, and
!?$"’‘.:,;*+-/|~ ^<=>#%@&()[]{}.
    Fu
(characterp foo)
  Fu                       ⊲ T if argument is of indicated type.
(standard-char-p char )
    Fu
(graphic-char-p character )
  Fu
(alpha-char-p character )
  Fu
(alphanumericp character )
        ⊲ T if character is visible, alphabetic, or alphanumeric, re-
        spectively.
    Fu
(upper-case-p character )
  Fu
(lower-case-p character )
  Fu
(both-case-p character )
        ⊲ Return T if character is uppercase, lowercase, or able to
        be in another case, respectively.
    Fu
(digit-char-p character [radix 10 ])
        ⊲ Return its weight if character is a digit, or NIL otherwise.
    Fu
(char= character + )
  Fu
(char/= character + )
       ⊲ Return T if all character s, or none, respectively, are equal.
    Fu
(char-equal character + )
  Fu
(char-not-equal character + )
        ⊲ Return T if all character s, or none, respectively, are equal
        ignoring case.
    Fu
(char> character + )
  Fu
(char>= character + )
  Fu
(char< character + )
  Fu
(char<= character + )
       ⊲ Return T if character s are monotonically decreasing,
       monotonically non-increasing, monotonically increasing, or
       monotonically non-decreasing, respectively.


6
Common Lisp Quick Reference
 Fu
(char-greaterp character + )
  Fu
(char-not-lessp character + )
  Fu
(char-lessp character + )
  Fu
(char-not-greaterp character + )
        ⊲ Return T if character s are monotonically decreasing,
        monotonically non-increasing, monotonically increasing, or
        monotonically non-decreasing, respectively, ignoring case.
 Fu
(char-upcase character )
  Fu
(char-downcase character )
        ⊲ Return corresponding uppercase/lowercase character, re-
        spectively.
 Fu
(digit-char i [radix 10 ])   ⊲ Character representing digit i.
 Fu
(char-name character )       ⊲ character ’s name if any, or NIL.
 Fu
(name-char foo)      ⊲ Character named foo if any, or NIL.
 Fu
(char-int character )
  Fu                         ⊲ Code of character .
(char-code character )
 Fu
(code-char code)             ⊲ Character with code.
co                                         Fu
char-code-limit      ⊲ Upper bound of (char-code char ); ≥ 96.
 Fu
(character c)        ⊲ Return #c.



3 Strings
Strings can as well be manipulated by array and sequence functions;
see pages 10 and 12.
 Fu
(stringp foo)
  Fu                         ⊲ T if foo is of indicated type.
(simple-string-p foo)
                                            
                        :start1 start-foo 0 
                                            
     Fu                                     
  string=                :start2 start-bar 0
( Fu           foo bar                        )
  string-equal          :end1 end-foo NIL 
                                            
                                            
                         :end2 end-bar NIL
        ⊲ Return T if subsequences of foo and bar are equal.
        Obey/ignore, respectively, case.
  Fu                        
 string{/= -not-equal}                                      
  Fu
 string{> -greaterp}        
                                        :start1 start-foo 0 
 
                            
                                       
                                                              
                                                               
   Fu                                      :start2 start-bar 0
( string{>= -not-lessp}         foo bar                          )
  Fu
 string{< -lessp}           
                                        :end1 end-foo NIL 
                                                              
 
                            
                                                             
  Fu                                     :end2 end-bar NIL
  string{<= -not-greaterp}
        ⊲ If foo is lexicographically not equal, greater, not less,
        less, or not greater, respectively, then return position of
        first mismatching character in foo. Otherwise return NIL.
        Obey/ignore, respectively, case.

 Fu                  :initial-element char
(make-string size                                 )
                     :element-type type character
          ⊲ Return string of length size.
 Fu
(
 string x )         
    Fu
 string-capitalize
    Fu                      :start start 0
( string-upcase        x                    )
  Fu                      :end end NIL
   string-downcase
         ⊲ Convert x (symbol, string, or character) into a string, a
         string with capitalized words, an all-uppercase string, or an
         all-lowercase string, respectively.
  Fu                
 nstring-capitalize
    Fu                             :start start 0
( nstring-upcase         string                   )
  Fu                             :end end NIL
   nstring-downcase
         ⊲ Convert string into a string with capitalized words, an
         all-uppercase string, or an all-lowercase string, respectively.
  Fu               
 string-trim
    Fu
                    
( string-left-trim     char-bag string)
  Fu               
   string-right-trim
         ⊲ Return string with all characters in sequence char-bag
         removed from both ends, from the beginning, or from the
         end, respectively.


                                                                      7
Common Lisp Quick Reference
    Fu
(char string i )
  Fu
(schar string i )
        ⊲ Return zero-indexed ith character of string ignor-
        ing/obeying, respectively, fill pointer. setfable.
                                              
                       :start start 0
                                              
                                               
                                              
  Fu                    :end end NIL
(parse-integer string                            )
                       :radix int 10
                                              
                                               
                                              
                        :junk-allowed bool NIL
        ⊲ Return integer parsed from string and index of parse end.
                                                           2




4 Conses
4.1 Predicates
    Fu
(consp foo)
  Fu                    ⊲ Return T if foo is of indicated type.
(listp foo)
    Fu
(endp list)
  Fu                    ⊲ Return T if list/foo is NIL.
(null foo)
    Fu
(atom foo)              ⊲ Return T if foo is not a cons.
    Fu
(tailp foo list)        ⊲ Return T if foo is a tail of list.
                                       
                  :test function #’eql 
 Fu
(member foo list     :test-not function )
                                       
                   :key function
      ⊲ Return tail of list starting with its first element matching
      foo. Return NIL if there is no such element.
      Fu
    member-if
(   Fu            test list [:key function])
    member-if-not
       ⊲ Return tail of list starting with its first element satisfying
       test. Return NIL if there is no such element.
                                             
                        :test function #’eql 
    Fu
(subsetp list-a list-b     :test-not function )
                                             
                         :key function
       ⊲ Return T if list-a is a subset of list-b.


4.2 Lists
    Fu
(cons foo bar )         ⊲ Return new cons (foo . bar ).
    Fu
(list foo ∗ )           ⊲ Return list of foos.
    Fu
(list∗ foo + )
         ⊲ Return list of foo s with last foo becoming cdr of last cons.
         Return foo if only one foo given.
    Fu
(make-list num [:initial-element foo NIL ])
       ⊲ New list with num elements set to foo.
    Fu
(list-length list)      ⊲ Length of list; NIL for circular list.
    Fu
(car list)              ⊲ Car of list or NIL if list is NIL. setfable.
    Fu
(cdr list)
  Fu                    ⊲ Cdr of list or NIL if list is NIL. setfable.
(rest list)
    Fu                                                         Fu
(nthcdr n list)         ⊲ Return tail of list after calling cdr n times.
      Fu   Fu      Fu    Fu     Fu   Fu          Fu   Fu
({first second third fourth fifth sixth . . . ninth tenth} list )
        ⊲ Return nth element of list if any, or NIL otherwise.
        setfable.
    Fu
(nth n list)            ⊲ Zero-indexed nth element of list. setfable.
 Fu
(cX r list )
                                                                  Fu
         ⊲ With X being one to four as and ds representing cars
               Fu         Fu                           Fu   Fu
         and cdrs, e.g. (cadr bar ) is equivalent to (car (cdr bar )).
         setfable.
    Fu
(last list [num 1 ])           ⊲ Return list of last num conses of list.



8
Common Lisp Quick Reference
        Fu
    butlast list
(    Fu              [num 1 ])         ⊲ list excluding last num conses.
    nbutlast list
        Fu
    rplaca
(    Fu     cons object)
    rplacd
          ⊲ Replace car, or cdr, respectively, of cons with object.
    Fu
(ldiff list foo)
         ⊲ If foo is a tail of list, return preceding part of list . Oth-
         erwise return list .
                                       
                  :test function #’eql 
    Fu
(adjoin foo list     :test-not function )
                                       
                   :key function
        ⊲ Return list if foo is already member of list. If not, return
          Fu
        (cons foo list ).

    M                                     Fu                  Fu
(pop place)            ⊲ Set place to (cdr place ), return (car place ).
    M                                     Fu
(push foo place)       ⊲ Set place to (cons foo place ).
                                          
                    :test function #’eql 
    M
(pushnew foo place     :test-not function )
                                          
                     :key function
                        Fu
       ⊲ Set place to (adjoin foo place ).
    Fu
(append [proper-list ∗ foo NIL ])
  Fu
(nconc [non-circular-list ∗ foo NIL ])
        ⊲ Return concatenated list or, with only one argument, foo.
        foo can be of any type.
    Fu
(revappend list foo)
  Fu
(nreconc list foo)
       ⊲ Return concatenated list after reversing order in list.
        Fu
    mapcar
(   Fu       function list + )
    maplist
         ⊲ Return list of return values of function successively in-
         voked with corresponding arguments, either cars or cdrs,
         respectively, from each list .
        Fu
    mapcan
(   Fu       function list + )
    mapcon
        ⊲ Return list of concatenated return values of function suc-
        cessively invoked with corresponding arguments, either cars
        or cdrs, respectively, from each list. function should return
        a list.
        Fu
    mapc
(   Fu     function list + )
    mapl
         ⊲ Return first list after successively applying function to
         corresponding arguments, either cars or cdrs, respectively,
         from each list. function should have some side effects.
    Fu
(copy-list list)       ⊲ Return copy of list with shared elements.



4.3 Association Lists
    Fu
(pairlis keys values [alist NIL ])
         ⊲ Prepend to alist an association list made from lists keys
         and values.
    Fu
(acons key value alist )
        ⊲ Return alist with a (key . value) pair added.
                                       
   Fu                 :test test #’eql 
  assoc
( Fu       foo alist     :test-not test )
  rassoc                               
                       :key function
   Fu
  assoc-if[-not]
( Fu               test alist [:key function])
  rassoc-if[-not]
        ⊲ First cons whose car, or cdr, respectively, satisfies test.
    Fu
(copy-alist alist)               ⊲ Return copy of alist.




                                                                           9
Common Lisp Quick Reference

4.4 Trees
    Fu               :test test #’eql
(tree-equal foo bar                   )
                     :test-not test
       ⊲ Return T if trees foo and bar have same shape and leaves
       satisfying test.
                                               
   Fu
  subst new old tree      :test function #’eql 
( Fu                         :test-not function )
  nsubst new old tree                          
                           :key function
       ⊲ Make copy of tree with each subtree or leaf matching old
       replaced by new .
     Fu
  subst-if[-not] new test tree
(  Fu                             [:key function])
  nsubst-if[-not] new test tree
        ⊲ Make copy of tree with each subtree or leaf satisfying test
        replaced by new .
                                                       
   Fu
  sublis association-list tree    :test function #’eql 
( Fu                                  :test-not function )
  nsublis association-list tree                        
                                    :key function
        ⊲ Make copy of tree with each subtree or leaf matching a
        key in association-list replaced by that key’s value.
    Fu
(copy-tree tree)    ⊲ Copy of tree with same shape and leaves.



4.5 Sets
  Fu                   
 intersection 
  Fu                   
 set-difference 
  Fu
                         
                         
                         
 
                    a b 
                         
 
 union                 
                                                   
  Fu
                 
                          :test function #’eql 
                         
  set-exclusive-or
( Fu                            :test-not function )
 nintersection
  Fu                                             
 
                   a b  :key function
                         
                         
 nset-difference
  Fu                    
                         
 
 nunion                 
                         
  Fu
                        
                      a b
  nset-exclusive-or
        ⊲ Return a ∩ b, a  b, a ∪ b, or a △ b, respectively, of lists a
        and b.



5 Arrays
5.1 Predicates
    Fu
(arrayp foo)
  Fu
(vectorp foo)
  Fu
(simple-vector-p foo)             ⊲ T if foo is of indicated type.
  Fu
(bit-vector-p foo)
  Fu
(simple-bit-vector-p foo)
    Fu
(adjustable-array-p array )
  Fu
(array-has-fill-pointer-p array)
        ⊲ T if array is adjustable/has a fill pointer, respectively.
    Fu
(array-in-bounds-p array [subscripts])
         ⊲ Return T if subscripts are in array ’s bounds.



5.2 Array Functions
     Fu
    make-array dimension-sizes :adjustable bool NIL
(    Fu
    adjust-array array dimension-sizes
                                                                  
          :element-type type T
         
         
                                                                   
                                                                   
                                                                   
          :fill-pointer {num bool } NIL
                                                                 
                                                                   
             :initial-element obj                                  )
         
          :initial-contents sequence                              
                                                                   
         
                                                                 
                                                                   
                                                                  
              :displaced-to array NIL [:displaced-index-offset i 0 ]
         ⊲ Return fresh, or readjust, respectively, vector or array.
    Fu
(aref array subscripts )
        ⊲ Return array element pointed to by subscripts. setfable.
    Fu
(row-major-aref array i)
       ⊲ Return ith element of array in row-major order. setfable.



10
Common Lisp Quick Reference

 Fu
(array-row-major-index array [subscripts])
        ⊲ Index in row-major order of the element denoted by
        subscripts.
 Fu
(array-dimensions array )
        ⊲ List containing the lengths of array ’s dimensions.
 Fu
(array-dimension array i)
        ⊲ Length of i th dimension of array .
 Fu
(array-total-size array )    ⊲ Number of elements in array .
 Fu
(array-rank array )          ⊲ Number of dimensions of array .
 Fu
(array-displacement array )         ⊲ Target array and offset.
                                                          2

Fu
(bit bit-array [subscripts])
  Fu
(sbit simple-bit-array [subscripts])
         ⊲ Return element of bit-array or of simple-bit-array. setf-
         able.
 Fu
(bit-not bit-array [result-bit-array NIL ])
        ⊲ Return result of bitwise negation of bit-array.          If
        result-bit-array is T, put result in bit-array; if it is NIL,
        make a new array for result.
  Fu       
 bit-eqv 
  Fu
 bit-and 
           
            
  Fu
           
 bit-andc1
           
            
  Fu
           
            
 
 bit-andc2
  Fu
           
            
  bit-nand
( Fu           bit-array-a bit-array-b [result-bit-array NIL ])
 bit-ior 
  Fu       
 bit-orc1 
           
  Fu
           
            
 
 bit-orc2 
  Fu
           
 bit-xor 
           
            
  Fu
           
            
  bit-nor
        ⊲ Return result of bitwise logical operations (cf. opera-
                   Fu
        tions of boole, p. 4) on bit-array-a and bit-array-b. If
        result-bit-array is T, put result in bit-array-a; if it is NIL,
        make a new array for result.
co
array-rank-limit      ⊲ Upper bound of array rank; ≥ 8.
co
array-dimension-limit
        ⊲ Upper bound of an array dimension; ≥ 1024.
co
array-total-size-limit       ⊲ Upper bound of array size; ≥ 1024.



5.3 Vector Functions
Vectors can as well be manipulated by sequence functions; see sec-
tion 6.
 Fu
(vector foo ∗ )       ⊲ Return fresh simple vector of foo s.
 Fu
(svref vector i)      ⊲ Return element i of simple vector . setfable.

 Fu
(vector-push foo vector )
        ⊲ Return NIL if vector ’s fill pointer equals size of vector .
        Otherwise replace element of vector pointed to by fill
        pointer with foo; then increment fill pointer.

 Fu
(vector-push-extend foo vector [num])
        ⊲ Replace element of vector pointed to by fill pointer with
        foo, then increment fill pointer. Extend vector ’s size by
        ≥ num if necessary.
 Fu
(vector-pop vector )
        ⊲ Return element of vector its fillpointer points to after
        decrementation.
 Fu
(fill-pointer vector )        ⊲ Fill pointer of vector . setfable.




                                                                    11
Common Lisp Quick Reference


6 Sequences
6.1 Sequence Predicates
     Fu
    every
(    Fu        test sequence + )
    notevery
          ⊲ Return NIL or T, respectively, as soon as test on any set
          of corresponding elements of sequences returns NIL.
     Fu
  some
(  Fu     test sequence + )
  notany
       ⊲ Return value of test or NIL, respectively, as soon as test
       on any set of corresponding elements of sequences returns
       non-NIL.
                                                       
                                  :from-end bool NIL 
                                                       
                                                       
                                  :test function #’eql 
                                 
                                                       
                                                        
                                  :test-not function 
                                                       
                                 
                                                       
                                                        
                                                       
 Fu                                :start1 start-a 0
(mismatch sequence-a sequence-b                           )
                                  :start2 start-b 0
                                                       
                                                        
                                 
                                  :end1 end-a NIL      
                                                        
                                 
                                                       
                                                        
                                 
                                  :end2 end-b NIL      
                                                        
                                 
                                                       
                                                        
                                                       
                                   :key function
       ⊲ Return position in sequence-a where sequence-a and
       sequence-b begin to mismatch. Return NIL if they match
       entirely.


6.2 Sequence Functions
    Fu
(make-sequence sequence-type size [:initial-element foo])
       ⊲ Make sequence of sequence-type with size elements.
    Fu
(concatenate type sequence ∗ )
       ⊲ Return concatenated sequence of type.
    Fu
(merge type sequence-a sequence-b test [:key function NIL ])
       ⊲ Return interleaved sequence of type. Merged sequence
       will be sorted if both sequence-a and sequence-b are sorted.

Fu                    :start start 0
(fill sequence foo                    )
                      :end end NIL
          ⊲ Return sequence after setting elements between start and
          end to foo.
    Fu
(length sequence)
        ⊲ Return length of sequence (being value of fill pointer if
        applicable).
                                               
                      :from-end bool NIL 
                                               
                      :test function
                                               
                                                
                     
                                         #’eql 
                                                
                                               
  Fu                      :test-not function
(count foo sequence                               )
                      :start start 0
                                               
                                                
                     
                      :end end NIL             
                                                
                     
                                               
                                                
                                               
                        :key function
        ⊲ Return number of elements in sequence which match foo.
                                                    
                                 :from-end bool NIL 
                                                    
    Fu                                              
   count-if                        :start start 0
( Fu            test sequence                          )
   count-if-not                  :end end NIL
                                                    
                                                     
                                                    
                                   :key function
        ⊲ Return number of elements in sequence which satisfy test.
Fu
(elt sequence index )
        ⊲ Return element of sequence pointed to by zero-indexed
        index . setfable.
    Fu
(subseq sequence start [end NIL ])
       ⊲ Return subsequence of sequence between start and end.
       setfable.
     Fu
    sort
(    Fu          sequence test [:key function])
    stable-sort
          ⊲ Return sequence sorted. Order of elements considered
          equal is not guaranteed/retained, respectively.
    Fu
(reverse sequence)
  Fu                       ⊲ Return sequence in reverse order.
(nreverse sequence)



12
Common Lisp Quick Reference
                                                    
                             :from-end bool NIL 
                                                    
                             :test function
                                                    
                                                     
                            
                                              #’eql 
                                                     
   Fu                                               
  find                           :test-not test
( Fu         foo sequence                              )
  position                   :start start 0
                                                    
                                                     
                            
                             :end end NIL           
                                                     
                            
                                                    
                                                     
                                                    
                              :key function
        ⊲ Return first element in sequence which matches foo, or
        its position relative to the begin of sequence, respectively.
  Fu                                                 
 find-if
  Fu            
                                   :from-end bool NIL 
                                                       
                                                     
  find-if-not                          :start start 0
( Fu                test sequence                         )
 position-if
                
                                   :end end NIL
                                                       
                                                        
  Fu                                                 
  position-if-not                     :key function
        ⊲ Return first element in sequence which satisfies test, or
        its position relative to the begin of sequence, respectively.
                                                        
                               :from-end bool NIL 
                                                        
                               :test function
                                                        
                                                         
                              
                                                  #’eql 
                                                         
                               :test-not function 
                                                        
                              
                                                        
                                                         
                                                        
  Fu                             :start1 start-a 0
(search sequence-a sequence-b                             )
                               :start2 start-b 0
                                                        
                                                         
                              
                               :end1 end-a NIL          
                                                         
                              
                                                        
                                                         
                              
                               :end2 end-b NIL          
                                                         
                              
                                                        
                                                         
                                                        
                                 :key function
        ⊲ Search sequence-b for a subsequence matching
        sequence-a. Return position in sequence-b, or NIL.
                                               
                         :from-end bool NIL 
                                               
                         :test function
                                               
                                                
                        
                                         #’eql 
                                                
                         :test-not function 
                                               
   Fu                                          
  remove foo sequence
( Fu                      :start start 0         )
  delete foo sequence   
                         :end end NIL          
                                                
                        
                                               
                                                
                        
                         :key function         
                                                
                        
                                               
                                                
                                               
                          :count count NIL
        ⊲ Make copy of sequence without elements matching foo.

  Fu                                              
 remove-if                     :from-end bool NIL 
                                                    
  Fu
                test sequence
                                :start start 0
                                                    
                                                     
  remove-if-not
( Fu                               :end end NIL         )
 delete-if
  Fu                                              
               test sequence 
                                :key function
                                
                                
                                                     
                                                     
                                                     
  delete-if-not
                                   :count count NIL
        ⊲ Make copy of sequence with all (or count ) elements sat-
        isfying test removed.
                                                      
                                :from-end bool NIL 
                                                      
                                :test function
                                                      
                                                       
                               
                                                #’eql 
                                                       
   Fu                                                 
  remove-duplicates sequence       :test-not function
( Fu                                                      )
  delete-duplicates sequence    :start start 0
                                                      
                                                       
                               
                                :end end NIL          
                                                       
                               
                                                      
                                                       
                                                      
                                 :key function
        ⊲ Make copy of sequence without duplicates.
                                                       
                                 :from-end bool NIL 
                                                       
                                 :test function
                                                       
                                                        
                                
                                                 #’eql 
                                                        
                                
                                 :test-not function   
   Fu                                                  
  substitute new old sequence
( Fu                              :start start 0          )
  nsubstitute new old sequence  :end end NIL          
                                                        
                                
                                                       
                                                        
                                
                                 :key function         
                                                        
                                
                                                       
                                                        
                                                       
                                  :count count NIL
        ⊲ Make copy of sequence with all (or count ) olds replaced
        by new .
  Fu                                                           
 substitute-if                              :from-end bool NIL 
                                                                 
  Fu
                    new test sequence      :start start 0
                                                                 
                                                                  
  substitute-if-not
( Fu                                            :end end NIL        )
 nsubstitute-if
  Fu                                                           
                     new test sequence 
                                             :key function
                                             
                                             
                                                                  
                                                                  
                                                                  
  nsubstitute-if-not
                                                :count count NIL
        ⊲ Make copy of sequence with all (or count ) elements sat-
        isfying test replaced by new .
                                                    
                                  :start1 start-a 0 
                                                    
                                                    
  Fu                               :start2 start-b 0
(replace sequence-a sequence-b                        )
                                  :end1 end-a NIL 
                                                    
                                                    
                                   :end2 end-b NIL
        ⊲ Replace elements of sequence-a with elements of
        sequence-b.


                                                                  13
Common Lisp Quick Reference

 Fu
(map type function sequence + )
       ⊲ Apply function successively to corresponding elements of
       the sequences. Return values as a sequence of type. If type
       is NIL, return NIL.

 Fu
(map-into result-sequence function sequence ∗ )
       ⊲ Store into result-sequence successively values of function
       applied to corresponding elements of the sequences.

                                                  
                           :initial-value foo NIL 
                          
                           :from-end bool NIL 
                                                  
                                                   
  Fu
(reduce function sequence    :start start 0         )
                          
                           :end end NIL           
                                                   
                          
                                                  
                                                   
                             :key function
       ⊲ Starting with the first two elements of sequence, apply
       function successively to its last return value together with
       the next element of sequence. Return last value of function.

 Fu
(copy-seq sequence)
        ⊲ Copy of sequence with shared elements.




7 Hash Tables
Key-value storage similar to hash tables can as well be achieved us-
ing association lists and property lists; see pages 9 and 16.

 Fu
(hash-table-p foo)        ⊲ Return T if foo is of type hash-table.

                        Fu Fu   Fu    Fu           
                 :test {eq eql equal equalp} #’eql 
                                                   
                                                   
(make-hash-table :size int
 Fu
                                                      )
                 :rehash-size num
                                                   
                                                    
                                                   
                  :rehash-threshold num
       ⊲ Make a hash table.

 Fu
(gethash key hash-table [default NIL ])
       ⊲ Return object with key if any or default otherwise; and
       T if found, NIL otherwise. setfable.
       2             2

 Fu
(hash-table-count hash-table)
        ⊲ Number of entries in hash-table.

 Fu
(remhash key hash-table)
       ⊲ Remove from hash-table entry with key and return T if it
       existed. Return NIL otherwise.

 Fu
(clrhash hash-table)      ⊲ Empty hash-table.

 Fu
(maphash function hash-table)
      ⊲ Iterate over hash-table calling function on key and value.
      Return NIL.

 M                                                               P
(with-hash-table-iterator (foo hash-table) (declare decl ∗ )∗ form ∗ )
        ⊲ Return values of form s. In forms, invocations of (foo)
        return: T if an entry is returned; its key; its value.
 Fu
(hash-table-test hash-table)
        ⊲ Test function used in hash-table.

 Fu
(hash-table-size hash-table)
  Fu
(hash-table-rehash-size hash-table)
  Fu
(hash-table-rehash-threshold hash-table)
        ⊲ Current size, rehash-size, or rehash-threshold, respec-
                           Fu
        tively, as used in make-hash-table.
 Fu
(sxhash foo)
                                            Fu
       ⊲ Hash code unique for any argument equal foo.




14
Common Lisp Quick Reference


8 Structures
 M
(defstruct
                                                                       
        foo
                                                                    
        
                                                                       
        
               
                  :conc-name                                         
                                                                      
        
               
                                                                     
                                                                      
        
               
                  (:conc-name [slot-prefix foo- ])                    
                                                                      
        
               
                                                                     
                                                                      
        
               
                  :constructor
                                                                  ∗   
                                                                      
        
               
                                                                     
                                                                      
        
               
                                                                     
                                                                      
        
        
        
                
                
                  (:constructor maker MAKE-foo [(ord-λ∗ )] )         
                                                                      
                                                                      
        
               
                                                                     
                                                                      
        
               
                  :copier                                            
                                                                      
        
               
                                                                     
                                                                      
        
               
                                                                     
                                                                      
               
                
                   (:copier [copier COPY-foo ])                       
        
        
               
                                                                  
                                                                    ∗ 
                                                                      
               
                                  slot                            
                                                                  
        (foo (:include struct
                                                :type sl-type       ) )
        
              
                                  (slot [init
                                                                ])  
                                                                    
        
              
                                               :read-only b         
                                                                      
        
              
                                                                   
                                                                      
        
              
                          list                                    
                                                                      
        
              
                                               :named               
                                                                      
        
               (:type vector
                                            )                       
                                                                      
        
              
                                              (:initial-offset n)  
                                                                      
        
              
                                                                     
                                                                      
        
              
               
                             (vector type)                            
                                                                      
        
              
                 (:print-object [o-printer ])                       
                                                                      
        
              
                                                                    
                                                                      
        
              
                                                                     
                                                                      
        
              
                    (:print-function [f-printer])                    
                                                                      
        
              
                                                                     
                                                                      
        
               :predicate
                                                                     
                                                                      
        
              
                                                                     
                                                                      
                   (:predicate [p-name foo-P ])
                                                  ∗
              slot
                                                 
                                                  
        [doc]                  :type slot-type        )
              
               (slot [init                     ])
                               :read-only bool 
        ⊲ Define structure foo together with functions MAKE-foo,
        COPY-foo and foo-P; and setfable accessors foo-slot . In-
        stances are of class foo or, if defstruct option :type is given,
        of the specified type. They can be created by (MAKE-foo
        {:slot value}∗ ) or, if ord-λ (see p. 16) is given, by (maker
        arg ∗ {:key value}∗ ). In the latter case, arg s and :keys
        correspond to the positional and keyword parameters de-
        fined in ord-λ whose var s in turn correspond to slot s.
                                                      gF
        :print-object/:print-function generate a print-object method
        for an instance bar of foo calling (o-printer bar stream )
        or (f-printer bar stream print-level), respectively. If :type
        without :named is given, no foo-P is created.
 Fu
(copy-structure structure)
        ⊲ Return copy of structure with shared slot values.



9 Control Structure
9.1 Predicates
Fu
(eq foo bar )       ⊲ T if foo and bar are identical.
Fu
(eql foo bar )
        ⊲ T if foo and bar are identical, or the same character, or
        numbers of the same type and value.
 Fu
(equal foo bar )
                                 Fu
        ⊲ T if foo and bar are eql, or are equivalent pathnames,
                              Fu
        or are conses with equal cars and cdrs, or are strings or
                         Fu
        bit-vectors with eql elements below their fill pointers.
 Fu
(equalp foo bar )
        ⊲ T if foo and bar are identical; or are the same character
        ignoring case; or are numbers of the same value ignoring
        type; or are equivalent pathnames; or are conses or arrays
                                   Fu
        of the same shape with equalp elements; or are structures
                                Fu
        of the same type with equalp elements; or are hash-tables of
        the same size with the same :test function, the same keys
                                         Fu
        in terms of :test function, and equalp elements.
 Fu
(not foo)   ⊲ T if foo is NIL; NIL otherwise.
 Fu
(boundp symbol )           ⊲ T if symbol is a special variable.
 Fu
(constantp foo [environment NIL ])
       ⊲ T if foo is a constant form.
 Fu
(functionp foo)     ⊲ T if foo is of type function.



                                                                     15
Common Lisp Quick Reference

    Fu       foo
(fboundp                )   ⊲ T if foo is a global function or macro.
             (setf foo)



9.2 Variables
        M
    defconstant
(    M            foo form [doc])
    defparameter
         ⊲ Assign value of form to global constant/dynamic variable
         foo.
    M
(defvar foo form [doc] )
        ⊲ Unless bound already, assign value of form to dynamic
        variable foo.
        M
    setf
(    M      {place form }∗ )
    psetf
          ⊲ Set places to primary values of forms. Return values of
          last form /NIL; work sequentially/in parallel, respectively.
        sO
    setq
(    M      {symbol form}∗ )
    psetq
          ⊲ Set symbol s to primary values of forms. Return value of
          last form /NIL; work sequentially/in parallel, respectively.

Fu
(set symbol foo)
        ⊲ Set symbol ’s value cell to foo. Deprecated.
    M
(multiple-value-setq vars form)
        ⊲ Set elements of vars to the values of form. Return form ’s
        primary value.

    M
(shiftf place + foo)
         ⊲ Store value of foo in rightmost place shifting values of
         places left, returning first place .

    M
(rotatef place ∗ )
        ⊲ Rotate values of places left, old first becoming new last
        place’s value. Return NIL.
    Fu
(makunbound foo)            ⊲ Delete special variable foo if any.
    Fu
(get symbol key default NIL )
  Fu
(getf place key default NIL )
        ⊲ First entry key from property list stored in symbol /in
        place, respectively, or default if there is no key. setfable.
    Fu
(get-properties property-list keys)
        ⊲ Return key and value of first entry from property-list
                             2
        matching a key from keys, and tail of property-list start-
                                          3
        ing with that key. Return NIL, NIL, and NIL if there was no
                                        2       3
        matching key in property-list .
    Fu
(remprop symbol key)
  M
(remf place key)
        ⊲ Remove first entry key from property list stored in
        symbol /in place, respectively. Return T if key was there,
        or NIL otherwise.



9.3 Functions
Below, ordinary lambda list (ord-λ∗ ) has the form
                                                   ∗
                   var
(var ∗ &optional                                     [&rest var ]
                   (var init NIL [supplied-p] )
                                                ∗
       var                                      
 &key     var
       (              init NIL [supplied-p] )
          (:key var )
                                                ∗
                              var
[&allow-other-keys] &aux                          ).
                              (var [init NIL ])

supplied-p is T if there is a corresponding argument. init forms can
refer to any init and supplied-p to their left.



16
Common Lisp Quick Reference
                                       
 M       foo (ord-λ∗ )                 
  defun                              ∗ ) (declare decl ∗ )∗ [doc]
(         (setf foo) (new-value ord-λ
 M                                     
  lambda (ord-λ∗ )
            P∗)
       form
       ⊲ Define a function named foo or (setf foo), or an anony-
       mous function, respectively, which applies forms to ord-λs.
             M                                         sO
       For defun, forms are enclosed in an implicit block named
       foo.
     sO
     flet       foo (ord-λ∗ )
(     sO    ((                                (declare local-decl ∗ )∗
     labels    (setf foo) (new-value ord-λ∗ )
                           P                           P
          [doc] local-form ∗ )∗ ) (declare decl ∗ )∗ form ∗ )
          ⊲ Evaluate forms with locally defined functions foo. Glob-
          ally defined functions of the same name are shadowed. Each
                                                      sO
          foo is also the name of an implicit block around its corre-
                                                   sO
                                  ∗ . Only for labels, functions foo are
          sponding local-form
          visible inside local-forms . Return values of form s.

    sO        foo
(function       M               )
              (lambda form ∗ )
          ⊲ Return lexically innermost function named foo or a lexi-
                              M
          cal closure of the lambda expression.

    Fu    function
(apply                       arg ∗ args)
          (setf function)
          ⊲ Values of function called with args and the list elements
                                                   Fu   Fu        Fu
          of args. setfable if function is one of aref, bit, and sbit.
    Fu
(funcall function arg∗ )       ⊲ Values of function called with arg s.
    sO
(multiple-value-call function form ∗ )
        ⊲ Call function with all the values of each form as its ar-
        guments. Return values returned by function .
    Fu
(values-list list)   ⊲ Return elements of list .
    Fu
(values foo ∗ )
        ⊲ Return as multiple values the primary values of the foos.
        setfable.
    Fu
(multiple-value-list form)            ⊲ List of the values of form .
    M
(nth-value n form )
        ⊲ Zero-indexed nth return value of form.
    Fu
(complement function)
       ⊲ Return new function with same arguments and same side
       effects as function, but with complementary truth value.
    Fu
(constantly foo)
       ⊲ Function of any number of arguments returning foo.
    Fu
(identity foo)       ⊲ Return foo.
    Fu
(function-lambda-expression function)
        ⊲ If available, return lambda expression of function, NIL if
                                                              2
        function was defined in an environment without bindings,
        and name of function.
               3


    Fu        foo
(fdefinition              )
              (setf foo)
          ⊲ Definition of global function foo. setfable.
    Fu
(fmakunbound foo)
       ⊲ Remove global function or macro definition foo.
co
call-arguments-limit
 co
lambda-parameters-limit
        ⊲ Upper bound of the number of function arguments or
        lambda list parameters, respectively; ≥ 50.
co
multiple-values-limit
        ⊲ Upper bound of the number of values a multiple value
        can have; ≥ 20.




                                                                         17
Common Lisp Quick Reference

9.4 Macros
Below, macro lambda list (macro-λ∗ ) has the form of either
                                      ∗
                      var
([&whole var ] [E ]               ∗)     [E ]
                      (macro-λ
                                                               ∗
            var                                                
[&optional      var                                                ] [E ]
           (                      init NIL [supplied-p] )
                (macro-λ∗ )
   &rest    rest-var
[                           ] [E ]
   &body    (macro-λ∗ )
                                                                       ∗
       var                                                            
       
                                                                     
                                                                       
         var                        
  &key                                                                     [E ]
       ((:key var
       
                                   )
                                          init NIL [supplied-p] )     
                                                                       
                    (macro-λ∗ )
                                                      ∗
                                 var
[&allow-other-keys] [&aux                               ] [E ])
                                 (var [init NIL ])
or                                    ∗
                      var
([&whole var ] [E ]                      [E ] [&optional
                      (macro-λ∗ )
                                               ∗
var                                           
    var                                            ] [E ] . rest-var ).
(                  init NIL [supplied-p] )
    (macro-λ∗ )
One toplevel [E ] may be replaced by &environment var . supplied-p
is T if there is a corresponding argument. init forms can refer to
any init and supplied-p to their left.
        M
    defmacro                        foo
(    Fu                                        (macro-λ∗ ) (declare
    define-compiler-macro            (setf foo)
                                P
            decl ∗ )∗ [doc] form ∗ )
            ⊲ Define macro foo which on evaluation as (foo tree) applies
            expanded form s to arguments from tree, which corresponds
            to tree-shaped macro-λs. forms are enclosed in an implicit
             sO
            block named foo.
    M
(define-symbol-macro foo form )
       ⊲ Define symbol macro foo which on evaluation evaluates
       expanded form.
    sO
(macrolet ((foo (macro-λ∗ ) (declare local-decl ∗ )∗ [doc]
                   P                            P
       macro-form ∗ )∗ ) (declare decl ∗ )∗ form ∗ )
       ⊲ Evaluate forms with locally defined mutually invisible
                                                     sO
       macros foo which are enclosed in implicit blocks of the same
       name.
    sO                                                                            P
(symbol-macrolet ((foo expansion-form )∗ ) (declare decl ∗ )∗ form ∗ )
       ⊲ Evaluate forms with locally defined symbol macros foo.
    M
(defsetf function
              updater [doc]
                                                                 P  )
              (setf-λ∗ ) (s-var ∗ ) (declare decl ∗ )∗ [doc] form ∗
            where defsetf lambda list (setf-λ∗ ) has the form (var ∗
                                                           ∗
                            var
             &optional                                        [&rest var ]
                            (var init NIL [supplied-p] )
                                                              ∗
                     var                                      
             &key        var
                     (                 init NIL [supplied-p] )
                         (:key var )
            [&allow-other-keys] &environment var )
            ⊲ Specify how to setf a place accessed by function.
            Short form: (setf (function arg ∗ ) value-form) is replaced
            by (updater arg ∗ value-form ); the latter must return
            value-form. Long form: on invocation of (setf (function
            arg ∗ ) value-form), forms must expand into code that sets
            the place accessed where setf-λ and s-var ∗ describe the ar-
            guments of function and the value(s) to be stored, respec-
            tively; and that returns the value(s) of s-var ∗ . forms are
                                        sO
            enclosed in an implicit block named function.
    M
(define-setf-expander function (macro-λ∗ ) (declare decl ∗ )∗ [doc]
            P
       form ∗ )
       ⊲ Specify how to setf a place accessed by function. On in-
       vocation of (setf (function arg ∗ ) value-form ), form ∗ must
       expand into code returning arg-vars, args, newval-vars,
                                                   Fu
       set-form, and get-form as described with get-setf-expansion
       where the elements of macro lambda list macro-λ∗ are
       bound to corresponding args. form s are enclosed in an im-
               sO
       plicit block named function.


18
Common Lisp Quick Reference

    Fu
(get-setf-expansion place [environment NIL ])
        ⊲ Return lists of temporary variables arg-vars and of cor-
        responding args as given with place, list newval-vars with
                    2                             3
        temporary variables corresponding to the new values, and
        set-form and get-form specifying in terms of arg-vars and
        4             5
        newval-vars how to setf and how to read place.
    M
(define-modify-macro foo ( &optional
                                      ∗
        var
                                         [&rest var ]) function [doc])
        (var init NIL [supplied-p] )
       ⊲ Define macro foo able to modify a place. On invocation
       of (foo place arg ∗ ), the value of function applied to place
       and args will be stored into place and returned.
co
lambda-list-keywords
       ⊲ List of macro lambda list keywords. These are at least:

            &whole var
              ⊲ Bind var to the entire macro call form.
            &optional var ∗
               ⊲ Bind var s to corresponding arguments if any.
            {&rest &body} var
               ⊲ Bind var to a list of remaining arguments.
            &key var ∗
               ⊲ Bind var s to corresponding keyword arguments.
            &allow-other-keys
                ⊲ Suppress keyword argument checking. Callers can do
                so using :allow-other-keys T.
            &environment var
               ⊲ Bind var to the lexical compilation environment.
                                                  sO
            &aux var ∗        ⊲ Bind var s as in let∗.



9.5 Control Flow
sO
(if test then [else NIL ])
         ⊲ Return values of then if test returns T; return values of
         else otherwise.
    M               P
(cond (test then ∗ test )∗ )
        ⊲ Return the values of the first then ∗ whose test returns T;
        return NIL if all tests return NIL.
        M
     when            P
(     M      test foo ∗ )
     unless
           ⊲ Evaluate foos and return their values if test returns T or
           NIL, respectively. Return NIL otherwise.

    M             (key ∗ )    P       otherwise      P
(case test (               foo ∗ )∗ (             bar ∗ ) NIL )
                  key                 T
            ⊲ Return the values of the first foo ∗ one of whose keys is
            eql test. Return values of bar s if there is no matching key.

        M
     ecase           (key ∗ )    P
(     M      test (           foo ∗ )∗ )
     ccase           key
           ⊲ Return the values of the first foo ∗ one of whose keys is
           eql test. Signal non-correctable/correctable type-error and
           return NIL if there is no matching key.
    M
(and form ∗ T )
        ⊲ Evaluate forms from left to right. Immediately return
        NIL if one form’s value is NIL. Return values of last form
        otherwise.
M
(or form ∗ NIL )
        ⊲ Evaluate forms from left to right. Immediately return
        primary value of first non-NIL-evaluating form, or all values
        if last form is reached. Return NIL if no form returns T.
    sO
(progn form ∗ NIL )
        ⊲ Evaluate forms sequentially. Return values of last form .



                                                                      19
Common Lisp Quick Reference
    sO
(multiple-value-prog1 form-r form ∗ )
  M
(prog1 form-r form ∗ )
  M
(prog2 form-a form-r form ∗ )
        ⊲ Evaluate forms in order. Return values/primary value,
        respectively, of form-r .
    sO                           ∗
    let     name                                          P
(    sO   (                      ) (declare decl ∗ )∗ form ∗ )
    let∗    (name [value NIL ])
         ⊲ Evaluate forms with names lexically bound (in parallel
         or sequentially, respectively) to values. Return values of
         forms.
        M                            ∗                        ∗
    prog       name                                      tag
(    M      (                       ) (declare decl ∗ )∗        )
    prog∗      (name [value NIL ])                       form
                       sO
         ⊲ Evaluate tagbody-like body with names lexically bound
         (in parallel or sequentially, respectively) to values. Return
                            M
         NIL or explicitly returned values. Implicitly, the whole form
               sO
         is a block named NIL.
    sO                       P
(progv symbols values form ∗ )
        ⊲ Evaluate forms with locally established dynamic bind-
        ings of symbols to values or NIL. Return values of form s.
    sO
(unwind-protect protected cleanup ∗ )
       ⊲ Evaluate protected and then, no matter how control
       leaves protected , cleanups. Return values of protected .
    M                                                     P
(destructuring-bind destruct-λ bar (declare decl ∗ )∗ form ∗ )
        ⊲ Evaluate forms with variables from tree destruct-λ bound
        to corresponding elements of tree bar , and return their
        values. destruct-λ resembles macro-λ (section 9.4), but
        without any &environment clause.
    M
(multiple-value-bind (var ∗ ) values-form (declare decl ∗ )∗
                  P
        body-form ∗ )
        ⊲ Evaluate body-form s with var s lexically bound to the re-
        turn values of values-form. Return values of body-form s.
    sO               P
(block name form ∗ )
        ⊲ Evaluate forms in a lexical environment, and return their
                                      sO
        values unless interrupted by return-from.
    sO
(return-from foo [result NIL ])
  M
(return [result NIL ])
                                    sO
        ⊲ Have nearest enclosing block named foo/named NIL, re-
        spectively, return with values of result.
    sO
(tagbody {tag form}∗ )
       ⊲ Evaluate forms in a lexical environment. tags (symbols
       or integers) have lexical scope and dynamic extent, and are
                   sO
       targets for go. Return NIL.
sO
(go tag)
                                                  sO
       ⊲ Within the innermost possible enclosing tagbody, jump
       to a tag eql tag.
    sO           P
(catch tag form ∗ )
        ⊲ Evaluate forms and return their values unless interrupted
            sO
        by throw.
    sO
(throw tag form)
                                                 sO
       ⊲ Have the nearest dynamically enclosing catch with a tag
       Fu
       eq tag return with the values of form.
    Fu
(sleep n)    ⊲ Wait n seconds, return NIL.


9.6 Iteration
    M                            ∗
    do     var                                P
(    M  (                       ) (stop result ∗ ) (declare decl ∗ )∗
    do∗    (var start [step] )
               ∗
          tag
                 )
          form
                      sO
        ⊲ Evaluate tagbody-like body with var s successively bound
        according to the values of the corresponding start and step
        forms. var s are bound in parallel/sequentially, respectively.
        Stop iteration when stop is T. Return values of result ∗ .
                                         sO
        Implicitly, the whole form is a block named NIL.


20
Common Lisp Quick Reference

 M
(dotimes (var i [result NIL ]) (declare decl ∗ )∗ {tag form}∗ )
                     sO
       ⊲ Evaluate tagbody-like body with var successively bound
       to integers from 0 to i − 1. Upon evaluation of result , var
                                                  sO
       is i. Implicitly, the whole form is a block named NIL.
 M
(dolist (var list [result NIL ]) (declare decl ∗ )∗ {tag form}∗ )
                       sO
         ⊲ Evaluate tagbody-like body with var successively bound
         to the elements of list. Upon evaluation of result , var is
                                                    sO
         NIL. Implicitly, the whole form is a block named NIL.



9.7 Loop Facility
 M
(loop form ∗ )
        ⊲ Simple Loop. If forms do not contain any atomic Loop
                                                                 sO
        Facility keywords, evaluate them forever in an implicit block
        named NIL.
 M
(loop clause ∗ )
        ⊲ Loop Facility. For Loop Facility keywords see below and
        Figure 1.

                                   M              sO
       named n NIL        ⊲ Give loop’s implicit block a name.
              var-s
       {with              [d-type] [= foo]}+
              (var-s ∗ )
                  var-p
           {and               [d-type] [= bar ]}∗
                  (var-p ∗ )
           where destructuring type specifier d-type has the form
                                           type
            fixnum float T NIL of-type
                                           (type ∗ )
           ⊲ Initialize (possibly trees of) local variables var-s se-
           quentially and var-p in parallel.
                  var-s                +         var-p               ∗
         {for as}             [d-type]     and              [d-type]
                  (var-s ∗ )                     (var-p ∗ )
           ⊲ Begin of iteration control clauses. Initialize and step
           (possibly trees of) local variables var-s sequentially and
           var-p in parallel. Destructuring type specifier d-type as
           with with.
           {upfrom from downfrom} start
              ⊲ Start stepping with start
           {upto downto to below above} form
              ⊲ Specify form as the end value for stepping.
           {in on} list
               ⊲ Bind var to successive elements/tails, respec-
               tively, of list.
           by {step 1 function #’cdr }
               ⊲ Specify the (positive) decrement or increment or
               the function of one argument returning the next
               part of the list.
           = foo [then bar foo ]
               ⊲ Bind var initially to foo and later to bar .
           across vector
               ⊲ Bind var to successive elements of vector .
           being {the each}
               ⊲ Iterate over a hash table or a package.
               {hash-key hash-keys} {of in} hash-table [using
                  (hash-value value)]
                  ⊲ Bind var successively to the keys of
                  hash-table; bind value to corresponding values.
               {hash-value hash-values} {of in} hash-table [using
                  (hash-key key)]
                  ⊲ Bind var successively to the values of
                  hash-table; bind key to corresponding keys.
               {symbol symbols present-symbol present-symbols
                  external-symbol external-symbols} [{of in}
                  package ∗package∗ ]
                            var

                  ⊲ Bind var successively to the accessible sym-
                  bols, or the present symbols, or the external
                  symbols respectively, of package.



                                                                   21
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec
Clqr a4-consec

More Related Content

What's hot (20)

OpenMP
OpenMPOpenMP
OpenMP
 
Fourier series
Fourier seriesFourier series
Fourier series
 
Joint Repairs for Web Wrappers
Joint Repairs for Web WrappersJoint Repairs for Web Wrappers
Joint Repairs for Web Wrappers
 
Rust Intro
Rust IntroRust Intro
Rust Intro
 
[ASM]Lab6
[ASM]Lab6[ASM]Lab6
[ASM]Lab6
 
Multirate sim
Multirate simMultirate sim
Multirate sim
 
Fourier series and fourier integral
Fourier series and fourier integralFourier series and fourier integral
Fourier series and fourier integral
 
Optics Fourier Transform Ii
Optics Fourier Transform IiOptics Fourier Transform Ii
Optics Fourier Transform Ii
 
5. fourier properties
5. fourier properties5. fourier properties
5. fourier properties
 
Discrete Fourier Series | Discrete Fourier Transform | Discrete Time Fourier ...
Discrete Fourier Series | Discrete Fourier Transform | Discrete Time Fourier ...Discrete Fourier Series | Discrete Fourier Transform | Discrete Time Fourier ...
Discrete Fourier Series | Discrete Fourier Transform | Discrete Time Fourier ...
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
ANSI C REFERENCE CARD
ANSI C REFERENCE CARDANSI C REFERENCE CARD
ANSI C REFERENCE CARD
 
Dart function - Recursive functions
Dart function - Recursive functionsDart function - Recursive functions
Dart function - Recursive functions
 
C reference card
C reference cardC reference card
C reference card
 
C Reference Card (Ansi) 2
C Reference Card (Ansi) 2C Reference Card (Ansi) 2
C Reference Card (Ansi) 2
 
Fourier transform
Fourier transformFourier transform
Fourier transform
 
Ch2
Ch2Ch2
Ch2
 
Fourier series
Fourier series Fourier series
Fourier series
 
07 periodic functions and fourier series
07 periodic functions and fourier series07 periodic functions and fourier series
07 periodic functions and fourier series
 
the fourier series
the fourier seriesthe fourier series
the fourier series
 

Viewers also liked

CLISP Lab Manual - Dr.J.VijiPriya
CLISP Lab Manual - Dr.J.VijiPriyaCLISP Lab Manual - Dr.J.VijiPriya
CLISP Lab Manual - Dr.J.VijiPriyaVijiPriya Jeyamani
 
Common lisp first steps beginner tutorial - wikibooks, open books for an open...
Common lisp first steps beginner tutorial - wikibooks, open books for an open...Common lisp first steps beginner tutorial - wikibooks, open books for an open...
Common lisp first steps beginner tutorial - wikibooks, open books for an open...ರಾಜು ತೊರವಿ
 
Lisp Programming Languge
Lisp Programming LangugeLisp Programming Languge
Lisp Programming LangugeYaser Jaradeh
 
LISP + GETVPN as alternative to DMVPN+OSPF+GETVPN
LISP + GETVPN as alternative to DMVPN+OSPF+GETVPNLISP + GETVPN as alternative to DMVPN+OSPF+GETVPN
LISP + GETVPN as alternative to DMVPN+OSPF+GETVPNJobSnijders
 
A brief introduction to lisp language
A brief introduction to lisp languageA brief introduction to lisp language
A brief introduction to lisp languageDavid Gu
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISPDevnology
 
LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)wahab khan
 
Functional Programming with LISP
Functional Programming with LISPFunctional Programming with LISP
Functional Programming with LISPAnil Kumar Pugalia
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lispkyleburton
 

Viewers also liked (18)

CLISP Lab Manual - Dr.J.VijiPriya
CLISP Lab Manual - Dr.J.VijiPriyaCLISP Lab Manual - Dr.J.VijiPriya
CLISP Lab Manual - Dr.J.VijiPriya
 
Common lisp first steps beginner tutorial - wikibooks, open books for an open...
Common lisp first steps beginner tutorial - wikibooks, open books for an open...Common lisp first steps beginner tutorial - wikibooks, open books for an open...
Common lisp first steps beginner tutorial - wikibooks, open books for an open...
 
(Lisp)
(Lisp)(Lisp)
(Lisp)
 
LISP: Input And Output
LISP: Input And OutputLISP: Input And Output
LISP: Input And Output
 
Lisp Programming Languge
Lisp Programming LangugeLisp Programming Languge
Lisp Programming Languge
 
LISP: Data types in lisp
LISP: Data types in lispLISP: Data types in lisp
LISP: Data types in lisp
 
LISP + GETVPN as alternative to DMVPN+OSPF+GETVPN
LISP + GETVPN as alternative to DMVPN+OSPF+GETVPNLISP + GETVPN as alternative to DMVPN+OSPF+GETVPN
LISP + GETVPN as alternative to DMVPN+OSPF+GETVPN
 
Lisp
LispLisp
Lisp
 
Lisp Book
Lisp BookLisp Book
Lisp Book
 
A Little Lisp
A Little LispA Little Lisp
A Little Lisp
 
A brief introduction to lisp language
A brief introduction to lisp languageA brief introduction to lisp language
A brief introduction to lisp language
 
Learn a language : LISP
Learn a language : LISPLearn a language : LISP
Learn a language : LISP
 
Funtional Programming
Funtional ProgrammingFuntional Programming
Funtional Programming
 
LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)LISP Programming Language (Artificial Intelligence)
LISP Programming Language (Artificial Intelligence)
 
Lisp
LispLisp
Lisp
 
Functional Programming with LISP
Functional Programming with LISPFunctional Programming with LISP
Functional Programming with LISP
 
Introduction To Lisp
Introduction To LispIntroduction To Lisp
Introduction To Lisp
 
LISP: Introduction to lisp
LISP: Introduction to lispLISP: Introduction to lisp
LISP: Introduction to lisp
 

Similar to Clqr a4-consec

openMP loop parallelization
openMP loop parallelizationopenMP loop parallelization
openMP loop parallelizationAlbert DeFusco
 
Introdution to differential forms
Introdution to differential formsIntrodution to differential forms
Introdution to differential formsDunga Pessoa
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)Ishin Vin
 
Function Analysis v.1
Function Analysis v.1Function Analysis v.1
Function Analysis v.1Arun Umrao
 
Principle of Function Analysis - by Arun Umrao
Principle of Function Analysis - by Arun UmraoPrinciple of Function Analysis - by Arun Umrao
Principle of Function Analysis - by Arun Umraossuserd6b1fd
 
Independence Complexes
Independence ComplexesIndependence Complexes
Independence ComplexesRickard Fors
 
yield and return (poor English ver)
yield and return (poor English ver)yield and return (poor English ver)
yield and return (poor English ver)bleis tift
 
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. PatilDiscrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patilwidespreadpromotion
 
Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2Iffat Anjum
 
Block Cipher vs. Stream Cipher
Block Cipher vs. Stream CipherBlock Cipher vs. Stream Cipher
Block Cipher vs. Stream CipherAmirul Wiramuda
 

Similar to Clqr a4-consec (20)

openMP loop parallelization
openMP loop parallelizationopenMP loop parallelization
openMP loop parallelization
 
Pairing scott
Pairing scottPairing scott
Pairing scott
 
Introdution to differential forms
Introdution to differential formsIntrodution to differential forms
Introdution to differential forms
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)
 
Sobolev spaces
Sobolev spacesSobolev spaces
Sobolev spaces
 
Function Analysis v.1
Function Analysis v.1Function Analysis v.1
Function Analysis v.1
 
Principle of Function Analysis - by Arun Umrao
Principle of Function Analysis - by Arun UmraoPrinciple of Function Analysis - by Arun Umrao
Principle of Function Analysis - by Arun Umrao
 
Independence Complexes
Independence ComplexesIndependence Complexes
Independence Complexes
 
recursion.ppt
recursion.pptrecursion.ppt
recursion.ppt
 
Manual de KmPlot
Manual de KmPlotManual de KmPlot
Manual de KmPlot
 
yield and return (poor English ver)
yield and return (poor English ver)yield and return (poor English ver)
yield and return (poor English ver)
 
Cookbook en
Cookbook enCookbook en
Cookbook en
 
c5.pdf
c5.pdfc5.pdf
c5.pdf
 
c5.pdf
c5.pdfc5.pdf
c5.pdf
 
Chapter 2 fourier transform
Chapter 2 fourier transformChapter 2 fourier transform
Chapter 2 fourier transform
 
PARSING.ppt
PARSING.pptPARSING.ppt
PARSING.ppt
 
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. PatilDiscrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
Discrete Mathematics S. Lipschutz, M. Lipson And V. H. Patil
 
Orthogonal_Polynomials
Orthogonal_PolynomialsOrthogonal_Polynomials
Orthogonal_Polynomials
 
Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2Lecture 05 syntax analysis 2
Lecture 05 syntax analysis 2
 
Block Cipher vs. Stream Cipher
Block Cipher vs. Stream CipherBlock Cipher vs. Stream Cipher
Block Cipher vs. Stream Cipher
 

Recently uploaded

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 

Recently uploaded (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 

Clqr a4-consec

  • 1. Quick Reference cl Common lisp Bert Burgemeister
  • 2. Common Lisp Quick Reference Contents 1 Numbers 3 9.5 Control Flow . . . 19 1.1 Predicates . . . . 3 9.6 Iteration . . . . 20 1.2 Numeric Functns . 3 9.7 Loop Facility . . . 21 1.3 Logic Functions . 4 10 CLOS 23 1.4 Integer Functions . 5 10.1 Classes . . . . . 23 1.5 Implementation- 10.2 Generic Functns . 25 Dependent . . . . 6 10.3 Method Combi- 2 Characters 6 nation Types . . . 26 3 Strings 7 11 Conditions and Errors 27 4 Conses 8 12 Types and Classes 29 4.1 Predicates . . . . 8 4.2 Lists . . . . . . 8 13 Input/Output 31 4.3 Association Lists . 9 13.1 Predicates . . . . 31 4.4 Trees . . . . . . 10 13.2 Reader . . . . . 31 4.5 Sets . . . . . . 10 13.3 Character Syntax . 33 13.4 Printer . . . . . 34 5 Arrays 10 13.5 Format . . . . . 36 5.1 Predicates . . . . 10 13.6 Streams . . . . . 38 5.2 Array Functions . 10 13.7 Paths and Files . . 40 5.3 Vector Functions . 11 14 Packages and Symbols 41 6 Sequences 12 14.1 Predicates . . . . 41 6.1 Seq. Predicates . . 12 14.2 Packages . . . . 41 6.2 Seq. Functions . . 12 14.3 Symbols . . . . . 43 7 Hash Tables 14 14.4 Std Packages . . 43 8 Structures 15 15 Compiler 43 15.1 Predicates . . . . 43 9 Control Structure 15 15.2 Compilation . . . 43 9.1 Predicates . . . . 15 15.3 REPL & Debug . 45 9.2 Variables . . . . 16 15.4 Declarations . . . 46 9.3 Functions . . . . 16 9.4 Macros . . . . . 18 16 External Environment 46 Typographic Conventions Fu M sO gF var co name; name; name; name; name; ∗name∗; name ⊲ Symbol defined in Common Lisp; esp. function, macro, special operator, generic function, variable, constant. them ⊲ Placeholder for actual code. me ⊲ Literal text. [foo bar ] ⊲ Either one foo or nothing; defaults to bar. foo ∗ ; {foo}∗ ⊲ Zero or more foos. foo + ; {foo}+ ⊲ One or more foos. foos ⊲ English plural denotes a list argument.  foo {foo bar baz }; bar ⊲ Either foo, or bar , or baz .  baz   foo bar ⊲ Anything from none to each of foo, bar , and baz .  baz foo ⊲ Argument foo is not evaluated. bar ⊲ Argument bar is possibly modified. P sO foo ∗ ⊲ foo ∗ is evaluated as in progn; see p. 19. foo; bar ; baz ⊲ Primary, secondary, and nth return value. 2 n T; NIL ⊲ t, or truth in general; and nil or (). 2
  • 3. Common Lisp Quick Reference 1 Numbers 1.1 Predicates Fu (= number + ) Fu (/= number + ) ⊲ T if all number s, or none, respectively, are equal in value. Fu (> number + ) Fu (>= number + ) Fu (< number + ) Fu (<= number + ) ⊲ Return T if number s are monotonically decreasing, monotonically non-increasing, monotonically increasing, or monotonically non-decreasing, respectively. Fu (minusp a) Fu (zerop a) ⊲ T if a < 0, a = 0, or a > 0, respectively. Fu (plusp a) Fu (evenp integer ) Fu ⊲ T if integer is even or odd, respectively. (oddp integer) Fu (numberp foo) Fu (realp foo) Fu (rationalp foo) Fu (floatp foo) ⊲ T if foo is of indicated type. Fu (integerp foo) Fu (complexp foo) Fu (random-state-p foo) 1.2 Numeric Functions Fu (+ a 0 ∗ ) Fu ⊲ Return a or a, respectively. (∗ a 1 ∗ ) Fu (– a b ∗ ) Fu (/ a b ∗ ) ⊲ Return a − b or a/ b, respectively. Without any bs, return −a or 1/a, respectively. Fu (1+ a) Fu ⊲ Return a + 1 or a − 1, respectively. (1– a) M incf ( M place [delta 1 ]) decf ⊲ Increment or decrement the value of place by delta. Re- turn new value. Fu (exp p) Fu ⊲ Return ep or bp , respectively. (expt b p) Fu (log a [b e ]) ⊲ Return logb a or, without b, ln a. Fu (sqrt n) √ Fu ⊲ n in complex or natural numbers, respectively. (isqrt n) Fu (lcm integer ∗ 1 ) Fu (gcd integer ∗ ) ⊲ Least common multiple or greatest common denomina- tor, respectively, of integers. (gcd) returns 0. co pi ⊲ long-float approximation of π, Ludolph’s number. Fu (sin a) Fu (cos a) ⊲ sin a, cos a, or tan a, respectively. (a in radians.) Fu (tan a) Fu (asin a) Fu ⊲ arcsin a or arccos a, respectively, in radians. (acos a) Fu a (atan a [b 1 ]) ⊲ arctan b in radians. Fu (sinh a) Fu (cosh a) ⊲ sinh a, cosh a, or tanh a, respectively. Fu (tanh a) 3
  • 4. Common Lisp Quick Reference Fu (asinh a) Fu (acosh a) ⊲ asinh a, acosh a, or atanh a, respectively. Fu (atanh a) Fu (cis a) ⊲ Return ei a = cos a + i sin a. Fu (conjugate a) ⊲ Return complex conjugate of a. Fu (max num + ) Fu ⊲ Greatest or least, respectively, of nums. (min num + )  Fu Fu  {round Fu  Fu fround}     {floor ffloor} ( Fu Fu n [d 1 ]) {ceiling fceiling}  Fu    Fu  {truncate ftruncate} ⊲ Return as integer or float, respectively, n/d rounded, or rounded towards −∞, +∞, or 0, respectively; and remain- 2 der. Fu mod ( Fu n d) rem Fu Fu ⊲ Same as floor or truncate, respectively, but return re- mainder only. Fu (random limit [state ∗random-state∗ ]) var ⊲ Return non-negative random number less than limit, and of the same type. Fu (make-random-state {state NIL T} NIL ) ⊲ Copy of random-state object state or of the current ran- dom state; or a randomly initialized fresh random state. var ∗random-state∗ ⊲ Current random state. Fu (float-sign num-a [num-b 1 ]) ⊲ num-b with num-a’s sign. Fu (signum n) ⊲ Number of magnitude 1 representing sign or phase of n. Fu (numerator rational ) Fu (denominator rational ) ⊲ Numerator or denominator, respectively, of rational ’s canonical form. Fu (realpart number ) Fu (imagpart number ) ⊲ Real part or imaginary part, respectively, of number . Fu (complex real [imag 0 ]) ⊲ Make a complex number. Fu (phase number ) ⊲ Angle of number ’s polar representation. Fu (abs n) ⊲ Return |n|. Fu (rational real ) Fu (rationalize real ) ⊲ Convert real to rational. Assume complete/limited accu- racy for real . Fu (float real [prototype 0.0F0 ]) ⊲ Convert real into float with type of prototype. 1.3 Logic Functions Negative integers are used in two’s complement representation. Fu (boole operation int-a int-b) ⊲ Return value of bitwise logical operation . operation s are co boole-1 ⊲ int-a. co boole-2 ⊲ int-b. co boole-c1 ⊲ ¬int-a. co boole-c2 ⊲ ¬int-b. co boole-set ⊲ All bits set. co boole-clr ⊲ All bits zero. 4
  • 5. Common Lisp Quick Reference co boole-eqv ⊲ int-a ≡ int-b. co boole-and ⊲ int-a ∧ int-b. co boole-andc1 ⊲ ¬int-a ∧ int-b. co boole-andc2 ⊲ int-a ∧ ¬int-b. co boole-nand ⊲ ¬(int-a ∧ int-b). co boole-ior ⊲ int-a ∨ int-b. co boole-orc1 ⊲ ¬int-a ∨ int-b. co boole-orc2 ⊲ int-a ∨ ¬int-b. co boole-xor ⊲ ¬(int-a ≡ int-b). co boole-nor ⊲ ¬(int-a ∨ int-b). Fu (lognot integer ) ⊲ ¬integer . Fu (logeqv integer ∗ ) Fu (logand integer ∗ ) ⊲ Return value of exclusive-nored or anded integer s, re- spectively. Without any integer , return −1. Fu (logandc1 int-a int-b) ⊲ ¬int-a ∧ int-b. Fu (logandc2 int-a int-b) ⊲ int-a ∧ ¬int-b. Fu (lognand int-a int-b) ⊲ ¬(int-a ∧ int-b). Fu (logxor integer ∗ ) Fu (logior integer ∗ ) ⊲ Return value of exclusive-ored or ored integer s, respec- tively. Without any integer, return 0. Fu (logorc1 int-a int-b) ⊲ ¬int-a ∨ int-b. Fu (logorc2 int-a int-b) ⊲ int-a ∨ ¬int-b. Fu (lognor int-a int-b) ⊲ ¬(int-a ∨ int-b). Fu (logbitp i integer ) ⊲ T if zero-indexed ith bit of integer is set. Fu (logtest int-a int-b) ⊲ Return T if there is any bit set in int-a which is set in int-b as well. Fu (logcount int) ⊲ Number of 1 bits in int ≥ 0, number of 0 bits in int < 0. 1.4 Integer Functions Fu (integer-length integer) ⊲ Number of bits necessary to represent integer . Fu (ldb-test byte-spec integer ) ⊲ Return T if any bit specified by byte-spec in integer is set. Fu (ash integer count) ⊲ Return copy of integer arithmetically shifted left by count adding zeros at the right, or, for count < 0, shifted right discarding bits. Fu (ldb byte-spec integer ) ⊲ Extract byte denoted by byte-spec from integer . setfable. Fu deposit-field ( Fu int-a byte-spec int-b) dpb ⊲ Return int-b with bits denoted by byte-spec replaced Fu by corresponding bits of int-a, or by the low (byte-size byte-spec) bits of int-a, respectively. Fu (mask-field byte-spec integer) ⊲ Return copy of integer with all bits unset but those de- noted by byte-spec. setfable. Fu (byte size position ) ⊲ Byte specifier for a byte of size bits starting at a weight of 2position . Fu (byte-size byte-spec) Fu (byte-position byte-spec) ⊲ Size or position, respectively, of byte-spec. 5
  • 6. Common Lisp Quick Reference 1.5 Implementation-Dependent co  short-float   co  single-float epsilon co - double-float negative-epsilon  co  long-float ⊲ Smallest possible number making a difference when added or subtracted, respectively. co  least-negative  short-float  co  least-negative-normalized single-float co - least-positive  double-float  co  least-positive-normalized long-float ⊲ Available numbers closest to −0 or +0, respectively.  short-float  co single-float  most-negative co - double-float most-positive long-float   fixnum ⊲ Available numbers closest to −∞ or +∞, respectively. Fu (decode-float n) Fu (integer-decode-float n) ⊲ Return significand, exponent, and sign of float n. 2 3 Fu (scale-float n [i ]) ⊲ With n’s radix b, return nbi . Fu (float-radix n) Fu (float-digits n) Fu (float-precision n) ⊲ Radix, number of digits in that radix, or precision in that radix, respectively, of float n. Fu (upgraded-complex-part-type foo [environment NIL ]) ⊲ Type of most specialized complex number able to hold parts of type foo. 2 Characters The standard-char type comprises a-z, A-Z, 0-9, Newline, Space, and !?$"’‘.:,;*+-/|~ ^<=>#%@&()[]{}. Fu (characterp foo) Fu ⊲ T if argument is of indicated type. (standard-char-p char ) Fu (graphic-char-p character ) Fu (alpha-char-p character ) Fu (alphanumericp character ) ⊲ T if character is visible, alphabetic, or alphanumeric, re- spectively. Fu (upper-case-p character ) Fu (lower-case-p character ) Fu (both-case-p character ) ⊲ Return T if character is uppercase, lowercase, or able to be in another case, respectively. Fu (digit-char-p character [radix 10 ]) ⊲ Return its weight if character is a digit, or NIL otherwise. Fu (char= character + ) Fu (char/= character + ) ⊲ Return T if all character s, or none, respectively, are equal. Fu (char-equal character + ) Fu (char-not-equal character + ) ⊲ Return T if all character s, or none, respectively, are equal ignoring case. Fu (char> character + ) Fu (char>= character + ) Fu (char< character + ) Fu (char<= character + ) ⊲ Return T if character s are monotonically decreasing, monotonically non-increasing, monotonically increasing, or monotonically non-decreasing, respectively. 6
  • 7. Common Lisp Quick Reference Fu (char-greaterp character + ) Fu (char-not-lessp character + ) Fu (char-lessp character + ) Fu (char-not-greaterp character + ) ⊲ Return T if character s are monotonically decreasing, monotonically non-increasing, monotonically increasing, or monotonically non-decreasing, respectively, ignoring case. Fu (char-upcase character ) Fu (char-downcase character ) ⊲ Return corresponding uppercase/lowercase character, re- spectively. Fu (digit-char i [radix 10 ]) ⊲ Character representing digit i. Fu (char-name character ) ⊲ character ’s name if any, or NIL. Fu (name-char foo) ⊲ Character named foo if any, or NIL. Fu (char-int character ) Fu ⊲ Code of character . (char-code character ) Fu (code-char code) ⊲ Character with code. co Fu char-code-limit ⊲ Upper bound of (char-code char ); ≥ 96. Fu (character c) ⊲ Return #c. 3 Strings Strings can as well be manipulated by array and sequence functions; see pages 10 and 12. Fu (stringp foo) Fu ⊲ T if foo is of indicated type. (simple-string-p foo)    :start1 start-foo 0    Fu   string= :start2 start-bar 0 ( Fu foo bar ) string-equal  :end1 end-foo NIL      :end2 end-bar NIL ⊲ Return T if subsequences of foo and bar are equal. Obey/ignore, respectively, case.  Fu  string{/= -not-equal}     Fu string{> -greaterp}    :start1 start-foo 0          Fu :start2 start-bar 0 ( string{>= -not-lessp} foo bar )  Fu string{< -lessp}    :end1 end-foo NIL           Fu  :end2 end-bar NIL string{<= -not-greaterp} ⊲ If foo is lexicographically not equal, greater, not less, less, or not greater, respectively, then return position of first mismatching character in foo. Otherwise return NIL. Obey/ignore, respectively, case. Fu :initial-element char (make-string size ) :element-type type character ⊲ Return string of length size. Fu ( string x )  Fu string-capitalize Fu :start start 0 ( string-upcase x )  Fu  :end end NIL string-downcase ⊲ Convert x (symbol, string, or character) into a string, a string with capitalized words, an all-uppercase string, or an all-lowercase string, respectively.  Fu  nstring-capitalize Fu :start start 0 ( nstring-upcase string )  Fu  :end end NIL nstring-downcase ⊲ Convert string into a string with capitalized words, an all-uppercase string, or an all-lowercase string, respectively.  Fu  string-trim Fu  ( string-left-trim char-bag string)  Fu  string-right-trim ⊲ Return string with all characters in sequence char-bag removed from both ends, from the beginning, or from the end, respectively. 7
  • 8. Common Lisp Quick Reference Fu (char string i ) Fu (schar string i ) ⊲ Return zero-indexed ith character of string ignor- ing/obeying, respectively, fill pointer. setfable.    :start start 0      Fu :end end NIL (parse-integer string )  :radix int 10      :junk-allowed bool NIL ⊲ Return integer parsed from string and index of parse end. 2 4 Conses 4.1 Predicates Fu (consp foo) Fu ⊲ Return T if foo is of indicated type. (listp foo) Fu (endp list) Fu ⊲ Return T if list/foo is NIL. (null foo) Fu (atom foo) ⊲ Return T if foo is not a cons. Fu (tailp foo list) ⊲ Return T if foo is a tail of list.    :test function #’eql  Fu (member foo list :test-not function )   :key function ⊲ Return tail of list starting with its first element matching foo. Return NIL if there is no such element. Fu member-if ( Fu test list [:key function]) member-if-not ⊲ Return tail of list starting with its first element satisfying test. Return NIL if there is no such element.    :test function #’eql  Fu (subsetp list-a list-b :test-not function )   :key function ⊲ Return T if list-a is a subset of list-b. 4.2 Lists Fu (cons foo bar ) ⊲ Return new cons (foo . bar ). Fu (list foo ∗ ) ⊲ Return list of foos. Fu (list∗ foo + ) ⊲ Return list of foo s with last foo becoming cdr of last cons. Return foo if only one foo given. Fu (make-list num [:initial-element foo NIL ]) ⊲ New list with num elements set to foo. Fu (list-length list) ⊲ Length of list; NIL for circular list. Fu (car list) ⊲ Car of list or NIL if list is NIL. setfable. Fu (cdr list) Fu ⊲ Cdr of list or NIL if list is NIL. setfable. (rest list) Fu Fu (nthcdr n list) ⊲ Return tail of list after calling cdr n times. Fu Fu Fu Fu Fu Fu Fu Fu ({first second third fourth fifth sixth . . . ninth tenth} list ) ⊲ Return nth element of list if any, or NIL otherwise. setfable. Fu (nth n list) ⊲ Zero-indexed nth element of list. setfable. Fu (cX r list ) Fu ⊲ With X being one to four as and ds representing cars Fu Fu Fu Fu and cdrs, e.g. (cadr bar ) is equivalent to (car (cdr bar )). setfable. Fu (last list [num 1 ]) ⊲ Return list of last num conses of list. 8
  • 9. Common Lisp Quick Reference Fu butlast list ( Fu [num 1 ]) ⊲ list excluding last num conses. nbutlast list Fu rplaca ( Fu cons object) rplacd ⊲ Replace car, or cdr, respectively, of cons with object. Fu (ldiff list foo) ⊲ If foo is a tail of list, return preceding part of list . Oth- erwise return list .    :test function #’eql  Fu (adjoin foo list :test-not function )   :key function ⊲ Return list if foo is already member of list. If not, return Fu (cons foo list ). M Fu Fu (pop place) ⊲ Set place to (cdr place ), return (car place ). M Fu (push foo place) ⊲ Set place to (cons foo place ).    :test function #’eql  M (pushnew foo place :test-not function )   :key function Fu ⊲ Set place to (adjoin foo place ). Fu (append [proper-list ∗ foo NIL ]) Fu (nconc [non-circular-list ∗ foo NIL ]) ⊲ Return concatenated list or, with only one argument, foo. foo can be of any type. Fu (revappend list foo) Fu (nreconc list foo) ⊲ Return concatenated list after reversing order in list. Fu mapcar ( Fu function list + ) maplist ⊲ Return list of return values of function successively in- voked with corresponding arguments, either cars or cdrs, respectively, from each list . Fu mapcan ( Fu function list + ) mapcon ⊲ Return list of concatenated return values of function suc- cessively invoked with corresponding arguments, either cars or cdrs, respectively, from each list. function should return a list. Fu mapc ( Fu function list + ) mapl ⊲ Return first list after successively applying function to corresponding arguments, either cars or cdrs, respectively, from each list. function should have some side effects. Fu (copy-list list) ⊲ Return copy of list with shared elements. 4.3 Association Lists Fu (pairlis keys values [alist NIL ]) ⊲ Prepend to alist an association list made from lists keys and values. Fu (acons key value alist ) ⊲ Return alist with a (key . value) pair added.   Fu  :test test #’eql  assoc ( Fu foo alist :test-not test ) rassoc   :key function Fu assoc-if[-not] ( Fu test alist [:key function]) rassoc-if[-not] ⊲ First cons whose car, or cdr, respectively, satisfies test. Fu (copy-alist alist) ⊲ Return copy of alist. 9
  • 10. Common Lisp Quick Reference 4.4 Trees Fu :test test #’eql (tree-equal foo bar ) :test-not test ⊲ Return T if trees foo and bar have same shape and leaves satisfying test.   Fu subst new old tree  :test function #’eql  ( Fu :test-not function ) nsubst new old tree   :key function ⊲ Make copy of tree with each subtree or leaf matching old replaced by new . Fu subst-if[-not] new test tree ( Fu [:key function]) nsubst-if[-not] new test tree ⊲ Make copy of tree with each subtree or leaf satisfying test replaced by new .   Fu sublis association-list tree  :test function #’eql  ( Fu :test-not function ) nsublis association-list tree   :key function ⊲ Make copy of tree with each subtree or leaf matching a key in association-list replaced by that key’s value. Fu (copy-tree tree) ⊲ Copy of tree with same shape and leaves. 4.5 Sets  Fu   intersection   Fu   set-difference   Fu      a b    union      Fu      :test function #’eql   set-exclusive-or ( Fu :test-not function ) nintersection  Fu     a b  :key function   nset-difference  Fu    nunion    Fu   a b nset-exclusive-or ⊲ Return a ∩ b, a b, a ∪ b, or a △ b, respectively, of lists a and b. 5 Arrays 5.1 Predicates Fu (arrayp foo) Fu (vectorp foo) Fu (simple-vector-p foo) ⊲ T if foo is of indicated type. Fu (bit-vector-p foo) Fu (simple-bit-vector-p foo) Fu (adjustable-array-p array ) Fu (array-has-fill-pointer-p array) ⊲ T if array is adjustable/has a fill pointer, respectively. Fu (array-in-bounds-p array [subscripts]) ⊲ Return T if subscripts are in array ’s bounds. 5.2 Array Functions Fu make-array dimension-sizes :adjustable bool NIL ( Fu adjust-array array dimension-sizes    :element-type type T       :fill-pointer {num bool } NIL     :initial-element obj )   :initial-contents sequence         :displaced-to array NIL [:displaced-index-offset i 0 ] ⊲ Return fresh, or readjust, respectively, vector or array. Fu (aref array subscripts ) ⊲ Return array element pointed to by subscripts. setfable. Fu (row-major-aref array i) ⊲ Return ith element of array in row-major order. setfable. 10
  • 11. Common Lisp Quick Reference Fu (array-row-major-index array [subscripts]) ⊲ Index in row-major order of the element denoted by subscripts. Fu (array-dimensions array ) ⊲ List containing the lengths of array ’s dimensions. Fu (array-dimension array i) ⊲ Length of i th dimension of array . Fu (array-total-size array ) ⊲ Number of elements in array . Fu (array-rank array ) ⊲ Number of dimensions of array . Fu (array-displacement array ) ⊲ Target array and offset. 2 Fu (bit bit-array [subscripts]) Fu (sbit simple-bit-array [subscripts]) ⊲ Return element of bit-array or of simple-bit-array. setf- able. Fu (bit-not bit-array [result-bit-array NIL ]) ⊲ Return result of bitwise negation of bit-array. If result-bit-array is T, put result in bit-array; if it is NIL, make a new array for result.  Fu  bit-eqv   Fu bit-and      Fu   bit-andc1     Fu     bit-andc2  Fu    bit-nand ( Fu bit-array-a bit-array-b [result-bit-array NIL ]) bit-ior   Fu  bit-orc1     Fu     bit-orc2   Fu   bit-xor      Fu    bit-nor ⊲ Return result of bitwise logical operations (cf. opera- Fu tions of boole, p. 4) on bit-array-a and bit-array-b. If result-bit-array is T, put result in bit-array-a; if it is NIL, make a new array for result. co array-rank-limit ⊲ Upper bound of array rank; ≥ 8. co array-dimension-limit ⊲ Upper bound of an array dimension; ≥ 1024. co array-total-size-limit ⊲ Upper bound of array size; ≥ 1024. 5.3 Vector Functions Vectors can as well be manipulated by sequence functions; see sec- tion 6. Fu (vector foo ∗ ) ⊲ Return fresh simple vector of foo s. Fu (svref vector i) ⊲ Return element i of simple vector . setfable. Fu (vector-push foo vector ) ⊲ Return NIL if vector ’s fill pointer equals size of vector . Otherwise replace element of vector pointed to by fill pointer with foo; then increment fill pointer. Fu (vector-push-extend foo vector [num]) ⊲ Replace element of vector pointed to by fill pointer with foo, then increment fill pointer. Extend vector ’s size by ≥ num if necessary. Fu (vector-pop vector ) ⊲ Return element of vector its fillpointer points to after decrementation. Fu (fill-pointer vector ) ⊲ Fill pointer of vector . setfable. 11
  • 12. Common Lisp Quick Reference 6 Sequences 6.1 Sequence Predicates Fu every ( Fu test sequence + ) notevery ⊲ Return NIL or T, respectively, as soon as test on any set of corresponding elements of sequences returns NIL. Fu some ( Fu test sequence + ) notany ⊲ Return value of test or NIL, respectively, as soon as test on any set of corresponding elements of sequences returns non-NIL.    :from-end bool NIL       :test function #’eql       :test-not function          Fu :start1 start-a 0 (mismatch sequence-a sequence-b )  :start2 start-b 0      :end1 end-a NIL         :end2 end-b NIL         :key function ⊲ Return position in sequence-a where sequence-a and sequence-b begin to mismatch. Return NIL if they match entirely. 6.2 Sequence Functions Fu (make-sequence sequence-type size [:initial-element foo]) ⊲ Make sequence of sequence-type with size elements. Fu (concatenate type sequence ∗ ) ⊲ Return concatenated sequence of type. Fu (merge type sequence-a sequence-b test [:key function NIL ]) ⊲ Return interleaved sequence of type. Merged sequence will be sorted if both sequence-a and sequence-b are sorted. Fu :start start 0 (fill sequence foo ) :end end NIL ⊲ Return sequence after setting elements between start and end to foo. Fu (length sequence) ⊲ Return length of sequence (being value of fill pointer if applicable).    :from-end bool NIL     :test function      #’eql     Fu :test-not function (count foo sequence )  :start start 0      :end end NIL         :key function ⊲ Return number of elements in sequence which match foo.    :from-end bool NIL    Fu   count-if :start start 0 ( Fu test sequence ) count-if-not  :end end NIL      :key function ⊲ Return number of elements in sequence which satisfy test. Fu (elt sequence index ) ⊲ Return element of sequence pointed to by zero-indexed index . setfable. Fu (subseq sequence start [end NIL ]) ⊲ Return subsequence of sequence between start and end. setfable. Fu sort ( Fu sequence test [:key function]) stable-sort ⊲ Return sequence sorted. Order of elements considered equal is not guaranteed/retained, respectively. Fu (reverse sequence) Fu ⊲ Return sequence in reverse order. (nreverse sequence) 12
  • 13. Common Lisp Quick Reference    :from-end bool NIL     :test function      #’eql   Fu   find :test-not test ( Fu foo sequence ) position  :start start 0      :end end NIL         :key function ⊲ Return first element in sequence which matches foo, or its position relative to the begin of sequence, respectively.  Fu    find-if  Fu    :from-end bool NIL        find-if-not :start start 0 ( Fu test sequence ) position-if     :end end NIL     Fu    position-if-not :key function ⊲ Return first element in sequence which satisfies test, or its position relative to the begin of sequence, respectively.    :from-end bool NIL     :test function      #’eql    :test-not function          Fu :start1 start-a 0 (search sequence-a sequence-b )  :start2 start-b 0      :end1 end-a NIL         :end2 end-b NIL         :key function ⊲ Search sequence-b for a subsequence matching sequence-a. Return position in sequence-b, or NIL.    :from-end bool NIL     :test function      #’eql    :test-not function    Fu   remove foo sequence ( Fu :start start 0 ) delete foo sequence   :end end NIL         :key function         :count count NIL ⊲ Make copy of sequence without elements matching foo.  Fu    remove-if   :from-end bool NIL     Fu  test sequence   :start start 0    remove-if-not ( Fu :end end NIL ) delete-if  Fu     test sequence    :key function      delete-if-not :count count NIL ⊲ Make copy of sequence with all (or count ) elements sat- isfying test removed.    :from-end bool NIL     :test function      #’eql   Fu   remove-duplicates sequence :test-not function ( Fu ) delete-duplicates sequence  :start start 0      :end end NIL         :key function ⊲ Make copy of sequence without duplicates.    :from-end bool NIL     :test function      #’eql     :test-not function   Fu   substitute new old sequence ( Fu :start start 0 ) nsubstitute new old sequence  :end end NIL         :key function         :count count NIL ⊲ Make copy of sequence with all (or count ) olds replaced by new .  Fu    substitute-if   :from-end bool NIL     Fu  new test sequence   :start start 0    substitute-if-not ( Fu :end end NIL ) nsubstitute-if  Fu     new test sequence    :key function      nsubstitute-if-not :count count NIL ⊲ Make copy of sequence with all (or count ) elements sat- isfying test replaced by new .    :start1 start-a 0      Fu :start2 start-b 0 (replace sequence-a sequence-b )  :end1 end-a NIL      :end2 end-b NIL ⊲ Replace elements of sequence-a with elements of sequence-b. 13
  • 14. Common Lisp Quick Reference Fu (map type function sequence + ) ⊲ Apply function successively to corresponding elements of the sequences. Return values as a sequence of type. If type is NIL, return NIL. Fu (map-into result-sequence function sequence ∗ ) ⊲ Store into result-sequence successively values of function applied to corresponding elements of the sequences.    :initial-value foo NIL    :from-end bool NIL     Fu (reduce function sequence :start start 0 )   :end end NIL       :key function ⊲ Starting with the first two elements of sequence, apply function successively to its last return value together with the next element of sequence. Return last value of function. Fu (copy-seq sequence) ⊲ Copy of sequence with shared elements. 7 Hash Tables Key-value storage similar to hash tables can as well be achieved us- ing association lists and property lists; see pages 9 and 16. Fu (hash-table-p foo) ⊲ Return T if foo is of type hash-table.  Fu Fu Fu Fu   :test {eq eql equal equalp} #’eql      (make-hash-table :size int Fu )  :rehash-size num      :rehash-threshold num ⊲ Make a hash table. Fu (gethash key hash-table [default NIL ]) ⊲ Return object with key if any or default otherwise; and T if found, NIL otherwise. setfable. 2 2 Fu (hash-table-count hash-table) ⊲ Number of entries in hash-table. Fu (remhash key hash-table) ⊲ Remove from hash-table entry with key and return T if it existed. Return NIL otherwise. Fu (clrhash hash-table) ⊲ Empty hash-table. Fu (maphash function hash-table) ⊲ Iterate over hash-table calling function on key and value. Return NIL. M P (with-hash-table-iterator (foo hash-table) (declare decl ∗ )∗ form ∗ ) ⊲ Return values of form s. In forms, invocations of (foo) return: T if an entry is returned; its key; its value. Fu (hash-table-test hash-table) ⊲ Test function used in hash-table. Fu (hash-table-size hash-table) Fu (hash-table-rehash-size hash-table) Fu (hash-table-rehash-threshold hash-table) ⊲ Current size, rehash-size, or rehash-threshold, respec- Fu tively, as used in make-hash-table. Fu (sxhash foo) Fu ⊲ Hash code unique for any argument equal foo. 14
  • 15. Common Lisp Quick Reference 8 Structures M (defstruct   foo           :conc-name             (:conc-name [slot-prefix foo- ])             :constructor ∗                     (:constructor maker MAKE-foo [(ord-λ∗ )] )              :copier                  (:copier [copier COPY-foo ])          ∗      slot       (foo (:include struct  :type sl-type ) )     (slot [init  ])         :read-only b               list        :named      (:type vector  )         (:initial-offset n)              (vector type)        (:print-object [o-printer ])                   (:print-function [f-printer])            :predicate          (:predicate [p-name foo-P ])   ∗ slot    [doc] :type slot-type )   (slot [init ]) :read-only bool  ⊲ Define structure foo together with functions MAKE-foo, COPY-foo and foo-P; and setfable accessors foo-slot . In- stances are of class foo or, if defstruct option :type is given, of the specified type. They can be created by (MAKE-foo {:slot value}∗ ) or, if ord-λ (see p. 16) is given, by (maker arg ∗ {:key value}∗ ). In the latter case, arg s and :keys correspond to the positional and keyword parameters de- fined in ord-λ whose var s in turn correspond to slot s. gF :print-object/:print-function generate a print-object method for an instance bar of foo calling (o-printer bar stream ) or (f-printer bar stream print-level), respectively. If :type without :named is given, no foo-P is created. Fu (copy-structure structure) ⊲ Return copy of structure with shared slot values. 9 Control Structure 9.1 Predicates Fu (eq foo bar ) ⊲ T if foo and bar are identical. Fu (eql foo bar ) ⊲ T if foo and bar are identical, or the same character, or numbers of the same type and value. Fu (equal foo bar ) Fu ⊲ T if foo and bar are eql, or are equivalent pathnames, Fu or are conses with equal cars and cdrs, or are strings or Fu bit-vectors with eql elements below their fill pointers. Fu (equalp foo bar ) ⊲ T if foo and bar are identical; or are the same character ignoring case; or are numbers of the same value ignoring type; or are equivalent pathnames; or are conses or arrays Fu of the same shape with equalp elements; or are structures Fu of the same type with equalp elements; or are hash-tables of the same size with the same :test function, the same keys Fu in terms of :test function, and equalp elements. Fu (not foo) ⊲ T if foo is NIL; NIL otherwise. Fu (boundp symbol ) ⊲ T if symbol is a special variable. Fu (constantp foo [environment NIL ]) ⊲ T if foo is a constant form. Fu (functionp foo) ⊲ T if foo is of type function. 15
  • 16. Common Lisp Quick Reference Fu foo (fboundp ) ⊲ T if foo is a global function or macro. (setf foo) 9.2 Variables M defconstant ( M foo form [doc]) defparameter ⊲ Assign value of form to global constant/dynamic variable foo. M (defvar foo form [doc] ) ⊲ Unless bound already, assign value of form to dynamic variable foo. M setf ( M {place form }∗ ) psetf ⊲ Set places to primary values of forms. Return values of last form /NIL; work sequentially/in parallel, respectively. sO setq ( M {symbol form}∗ ) psetq ⊲ Set symbol s to primary values of forms. Return value of last form /NIL; work sequentially/in parallel, respectively. Fu (set symbol foo) ⊲ Set symbol ’s value cell to foo. Deprecated. M (multiple-value-setq vars form) ⊲ Set elements of vars to the values of form. Return form ’s primary value. M (shiftf place + foo) ⊲ Store value of foo in rightmost place shifting values of places left, returning first place . M (rotatef place ∗ ) ⊲ Rotate values of places left, old first becoming new last place’s value. Return NIL. Fu (makunbound foo) ⊲ Delete special variable foo if any. Fu (get symbol key default NIL ) Fu (getf place key default NIL ) ⊲ First entry key from property list stored in symbol /in place, respectively, or default if there is no key. setfable. Fu (get-properties property-list keys) ⊲ Return key and value of first entry from property-list 2 matching a key from keys, and tail of property-list start- 3 ing with that key. Return NIL, NIL, and NIL if there was no 2 3 matching key in property-list . Fu (remprop symbol key) M (remf place key) ⊲ Remove first entry key from property list stored in symbol /in place, respectively. Return T if key was there, or NIL otherwise. 9.3 Functions Below, ordinary lambda list (ord-λ∗ ) has the form ∗ var (var ∗ &optional [&rest var ] (var init NIL [supplied-p] )  ∗ var  &key var ( init NIL [supplied-p] ) (:key var ) ∗ var [&allow-other-keys] &aux ). (var [init NIL ]) supplied-p is T if there is a corresponding argument. init forms can refer to any init and supplied-p to their left. 16
  • 17. Common Lisp Quick Reference   M foo (ord-λ∗ )  defun ∗ ) (declare decl ∗ )∗ [doc] ( (setf foo) (new-value ord-λ M  lambda (ord-λ∗ ) P∗) form ⊲ Define a function named foo or (setf foo), or an anony- mous function, respectively, which applies forms to ord-λs. M sO For defun, forms are enclosed in an implicit block named foo. sO flet foo (ord-λ∗ ) ( sO (( (declare local-decl ∗ )∗ labels (setf foo) (new-value ord-λ∗ ) P P [doc] local-form ∗ )∗ ) (declare decl ∗ )∗ form ∗ ) ⊲ Evaluate forms with locally defined functions foo. Glob- ally defined functions of the same name are shadowed. Each sO foo is also the name of an implicit block around its corre- sO ∗ . Only for labels, functions foo are sponding local-form visible inside local-forms . Return values of form s. sO foo (function M ) (lambda form ∗ ) ⊲ Return lexically innermost function named foo or a lexi- M cal closure of the lambda expression. Fu function (apply arg ∗ args) (setf function) ⊲ Values of function called with args and the list elements Fu Fu Fu of args. setfable if function is one of aref, bit, and sbit. Fu (funcall function arg∗ ) ⊲ Values of function called with arg s. sO (multiple-value-call function form ∗ ) ⊲ Call function with all the values of each form as its ar- guments. Return values returned by function . Fu (values-list list) ⊲ Return elements of list . Fu (values foo ∗ ) ⊲ Return as multiple values the primary values of the foos. setfable. Fu (multiple-value-list form) ⊲ List of the values of form . M (nth-value n form ) ⊲ Zero-indexed nth return value of form. Fu (complement function) ⊲ Return new function with same arguments and same side effects as function, but with complementary truth value. Fu (constantly foo) ⊲ Function of any number of arguments returning foo. Fu (identity foo) ⊲ Return foo. Fu (function-lambda-expression function) ⊲ If available, return lambda expression of function, NIL if 2 function was defined in an environment without bindings, and name of function. 3 Fu foo (fdefinition ) (setf foo) ⊲ Definition of global function foo. setfable. Fu (fmakunbound foo) ⊲ Remove global function or macro definition foo. co call-arguments-limit co lambda-parameters-limit ⊲ Upper bound of the number of function arguments or lambda list parameters, respectively; ≥ 50. co multiple-values-limit ⊲ Upper bound of the number of values a multiple value can have; ≥ 20. 17
  • 18. Common Lisp Quick Reference 9.4 Macros Below, macro lambda list (macro-λ∗ ) has the form of either ∗ var ([&whole var ] [E ] ∗) [E ] (macro-λ  ∗  var  [&optional var ] [E ] ( init NIL [supplied-p] ) (macro-λ∗ ) &rest rest-var [ ] [E ] &body (macro-λ∗ )   ∗ var       var  &key [E ] ((:key var   ) init NIL [supplied-p] )   (macro-λ∗ ) ∗ var [&allow-other-keys] [&aux ] [E ]) (var [init NIL ]) or ∗ var ([&whole var ] [E ] [E ] [&optional (macro-λ∗ )   ∗ var  var ] [E ] . rest-var ). ( init NIL [supplied-p] ) (macro-λ∗ ) One toplevel [E ] may be replaced by &environment var . supplied-p is T if there is a corresponding argument. init forms can refer to any init and supplied-p to their left. M defmacro foo ( Fu (macro-λ∗ ) (declare define-compiler-macro (setf foo) P decl ∗ )∗ [doc] form ∗ ) ⊲ Define macro foo which on evaluation as (foo tree) applies expanded form s to arguments from tree, which corresponds to tree-shaped macro-λs. forms are enclosed in an implicit sO block named foo. M (define-symbol-macro foo form ) ⊲ Define symbol macro foo which on evaluation evaluates expanded form. sO (macrolet ((foo (macro-λ∗ ) (declare local-decl ∗ )∗ [doc] P P macro-form ∗ )∗ ) (declare decl ∗ )∗ form ∗ ) ⊲ Evaluate forms with locally defined mutually invisible sO macros foo which are enclosed in implicit blocks of the same name. sO P (symbol-macrolet ((foo expansion-form )∗ ) (declare decl ∗ )∗ form ∗ ) ⊲ Evaluate forms with locally defined symbol macros foo. M (defsetf function updater [doc] P ) (setf-λ∗ ) (s-var ∗ ) (declare decl ∗ )∗ [doc] form ∗ where defsetf lambda list (setf-λ∗ ) has the form (var ∗ ∗ var &optional [&rest var ] (var init NIL [supplied-p] )  ∗ var  &key var ( init NIL [supplied-p] ) (:key var ) [&allow-other-keys] &environment var ) ⊲ Specify how to setf a place accessed by function. Short form: (setf (function arg ∗ ) value-form) is replaced by (updater arg ∗ value-form ); the latter must return value-form. Long form: on invocation of (setf (function arg ∗ ) value-form), forms must expand into code that sets the place accessed where setf-λ and s-var ∗ describe the ar- guments of function and the value(s) to be stored, respec- tively; and that returns the value(s) of s-var ∗ . forms are sO enclosed in an implicit block named function. M (define-setf-expander function (macro-λ∗ ) (declare decl ∗ )∗ [doc] P form ∗ ) ⊲ Specify how to setf a place accessed by function. On in- vocation of (setf (function arg ∗ ) value-form ), form ∗ must expand into code returning arg-vars, args, newval-vars, Fu set-form, and get-form as described with get-setf-expansion where the elements of macro lambda list macro-λ∗ are bound to corresponding args. form s are enclosed in an im- sO plicit block named function. 18
  • 19. Common Lisp Quick Reference Fu (get-setf-expansion place [environment NIL ]) ⊲ Return lists of temporary variables arg-vars and of cor- responding args as given with place, list newval-vars with 2 3 temporary variables corresponding to the new values, and set-form and get-form specifying in terms of arg-vars and 4 5 newval-vars how to setf and how to read place. M (define-modify-macro foo ( &optional ∗ var [&rest var ]) function [doc]) (var init NIL [supplied-p] ) ⊲ Define macro foo able to modify a place. On invocation of (foo place arg ∗ ), the value of function applied to place and args will be stored into place and returned. co lambda-list-keywords ⊲ List of macro lambda list keywords. These are at least: &whole var ⊲ Bind var to the entire macro call form. &optional var ∗ ⊲ Bind var s to corresponding arguments if any. {&rest &body} var ⊲ Bind var to a list of remaining arguments. &key var ∗ ⊲ Bind var s to corresponding keyword arguments. &allow-other-keys ⊲ Suppress keyword argument checking. Callers can do so using :allow-other-keys T. &environment var ⊲ Bind var to the lexical compilation environment. sO &aux var ∗ ⊲ Bind var s as in let∗. 9.5 Control Flow sO (if test then [else NIL ]) ⊲ Return values of then if test returns T; return values of else otherwise. M P (cond (test then ∗ test )∗ ) ⊲ Return the values of the first then ∗ whose test returns T; return NIL if all tests return NIL. M when P ( M test foo ∗ ) unless ⊲ Evaluate foos and return their values if test returns T or NIL, respectively. Return NIL otherwise. M (key ∗ ) P otherwise P (case test ( foo ∗ )∗ ( bar ∗ ) NIL ) key T ⊲ Return the values of the first foo ∗ one of whose keys is eql test. Return values of bar s if there is no matching key. M ecase (key ∗ ) P ( M test ( foo ∗ )∗ ) ccase key ⊲ Return the values of the first foo ∗ one of whose keys is eql test. Signal non-correctable/correctable type-error and return NIL if there is no matching key. M (and form ∗ T ) ⊲ Evaluate forms from left to right. Immediately return NIL if one form’s value is NIL. Return values of last form otherwise. M (or form ∗ NIL ) ⊲ Evaluate forms from left to right. Immediately return primary value of first non-NIL-evaluating form, or all values if last form is reached. Return NIL if no form returns T. sO (progn form ∗ NIL ) ⊲ Evaluate forms sequentially. Return values of last form . 19
  • 20. Common Lisp Quick Reference sO (multiple-value-prog1 form-r form ∗ ) M (prog1 form-r form ∗ ) M (prog2 form-a form-r form ∗ ) ⊲ Evaluate forms in order. Return values/primary value, respectively, of form-r . sO ∗ let name P ( sO ( ) (declare decl ∗ )∗ form ∗ ) let∗ (name [value NIL ]) ⊲ Evaluate forms with names lexically bound (in parallel or sequentially, respectively) to values. Return values of forms. M ∗ ∗ prog name tag ( M ( ) (declare decl ∗ )∗ ) prog∗ (name [value NIL ]) form sO ⊲ Evaluate tagbody-like body with names lexically bound (in parallel or sequentially, respectively) to values. Return M NIL or explicitly returned values. Implicitly, the whole form sO is a block named NIL. sO P (progv symbols values form ∗ ) ⊲ Evaluate forms with locally established dynamic bind- ings of symbols to values or NIL. Return values of form s. sO (unwind-protect protected cleanup ∗ ) ⊲ Evaluate protected and then, no matter how control leaves protected , cleanups. Return values of protected . M P (destructuring-bind destruct-λ bar (declare decl ∗ )∗ form ∗ ) ⊲ Evaluate forms with variables from tree destruct-λ bound to corresponding elements of tree bar , and return their values. destruct-λ resembles macro-λ (section 9.4), but without any &environment clause. M (multiple-value-bind (var ∗ ) values-form (declare decl ∗ )∗ P body-form ∗ ) ⊲ Evaluate body-form s with var s lexically bound to the re- turn values of values-form. Return values of body-form s. sO P (block name form ∗ ) ⊲ Evaluate forms in a lexical environment, and return their sO values unless interrupted by return-from. sO (return-from foo [result NIL ]) M (return [result NIL ]) sO ⊲ Have nearest enclosing block named foo/named NIL, re- spectively, return with values of result. sO (tagbody {tag form}∗ ) ⊲ Evaluate forms in a lexical environment. tags (symbols or integers) have lexical scope and dynamic extent, and are sO targets for go. Return NIL. sO (go tag) sO ⊲ Within the innermost possible enclosing tagbody, jump to a tag eql tag. sO P (catch tag form ∗ ) ⊲ Evaluate forms and return their values unless interrupted sO by throw. sO (throw tag form) sO ⊲ Have the nearest dynamically enclosing catch with a tag Fu eq tag return with the values of form. Fu (sleep n) ⊲ Wait n seconds, return NIL. 9.6 Iteration M ∗ do var P ( M ( ) (stop result ∗ ) (declare decl ∗ )∗ do∗ (var start [step] ) ∗ tag ) form sO ⊲ Evaluate tagbody-like body with var s successively bound according to the values of the corresponding start and step forms. var s are bound in parallel/sequentially, respectively. Stop iteration when stop is T. Return values of result ∗ . sO Implicitly, the whole form is a block named NIL. 20
  • 21. Common Lisp Quick Reference M (dotimes (var i [result NIL ]) (declare decl ∗ )∗ {tag form}∗ ) sO ⊲ Evaluate tagbody-like body with var successively bound to integers from 0 to i − 1. Upon evaluation of result , var sO is i. Implicitly, the whole form is a block named NIL. M (dolist (var list [result NIL ]) (declare decl ∗ )∗ {tag form}∗ ) sO ⊲ Evaluate tagbody-like body with var successively bound to the elements of list. Upon evaluation of result , var is sO NIL. Implicitly, the whole form is a block named NIL. 9.7 Loop Facility M (loop form ∗ ) ⊲ Simple Loop. If forms do not contain any atomic Loop sO Facility keywords, evaluate them forever in an implicit block named NIL. M (loop clause ∗ ) ⊲ Loop Facility. For Loop Facility keywords see below and Figure 1. M sO named n NIL ⊲ Give loop’s implicit block a name. var-s {with [d-type] [= foo]}+ (var-s ∗ ) var-p {and [d-type] [= bar ]}∗ (var-p ∗ ) where destructuring type specifier d-type has the form type fixnum float T NIL of-type (type ∗ ) ⊲ Initialize (possibly trees of) local variables var-s se- quentially and var-p in parallel. var-s + var-p ∗ {for as} [d-type] and [d-type] (var-s ∗ ) (var-p ∗ ) ⊲ Begin of iteration control clauses. Initialize and step (possibly trees of) local variables var-s sequentially and var-p in parallel. Destructuring type specifier d-type as with with. {upfrom from downfrom} start ⊲ Start stepping with start {upto downto to below above} form ⊲ Specify form as the end value for stepping. {in on} list ⊲ Bind var to successive elements/tails, respec- tively, of list. by {step 1 function #’cdr } ⊲ Specify the (positive) decrement or increment or the function of one argument returning the next part of the list. = foo [then bar foo ] ⊲ Bind var initially to foo and later to bar . across vector ⊲ Bind var to successive elements of vector . being {the each} ⊲ Iterate over a hash table or a package. {hash-key hash-keys} {of in} hash-table [using (hash-value value)] ⊲ Bind var successively to the keys of hash-table; bind value to corresponding values. {hash-value hash-values} {of in} hash-table [using (hash-key key)] ⊲ Bind var successively to the values of hash-table; bind key to corresponding keys. {symbol symbols present-symbol present-symbols external-symbol external-symbols} [{of in} package ∗package∗ ] var ⊲ Bind var successively to the accessible sym- bols, or the present symbols, or the external symbols respectively, of package. 21