0% found this document useful (0 votes)
8 views52 pages

(2009) Lisp Quick Reference - Burgemeister

Uploaded by

rouboudoux
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views52 pages

(2009) Lisp Quick Reference - Burgemeister

Uploaded by

rouboudoux
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

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 . 24
Dependent . . . . 6
10.3 Method Combi-
2 Characters 6 nation Types . . . 26
3 Strings 7 11 Conditions and Errors 27
4 Conses 8 12 Input/Output 29
4.1 Predicates . . . . 8 12.1 Predicates . . . . 29
4.2 Lists . . . . . . 8 12.2 Reader . . . . . 30
4.3 Association Lists . 9 12.3 Macro Chars . . . 31
4.4 Trees . . . . . . 10 12.4 Printer . . . . . 32
4.5 Sets . . . . . . 10 12.5 Format . . . . . 34
5 Arrays 10 12.6 Streams . . . . . 36
5.1 Predicates . . . . 10 12.7 Files . . . . . . 37
5.2 Array Functions . 10 13 Types and Classes 39
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 . . . . . 42
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 . 44
9.2 Variables . . . . 16
15.4 Declarations . . . 45
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.


8
<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

c
foo ⊲ Argument foo is not evaluated.

g
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 ∗ ) P Q
Fu ⊲ Return a or a, respectively.
(∗ a 1 ∗ )
Fu
(– a b ∗ )
Fu
(/ a b ∗ ) P Q
⊲ 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 ff
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]) ⊲ 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 + )
8 Fu Fu 9
>
>{round fround} >
>
< Fu Fu =
{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 ff
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 the sign of num-a.
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 single-float ])
⊲ 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 ff
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 9
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 98
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.
8
>short-float
co ff>>
<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
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 )
⊲ Name of character if there is one, or NIL.
Fu
(name-char name)
⊲ Character with name if there is one, 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)
8˛ 9
> ˛:start1 start-foo 0 >
 Fu ff <˛˛
> >
=
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.
8 Fu 9 8˛ 9
>string/= > ˛:start1 start-foo 0 >
> Fu
> >
> >
>˛ >
<string> = <˛ =
Fu :start2 start-bar 0
( string>= foo bar ˛˛ )
>
> Fu >
> >
>˛ :end1 end-foo NIL >>
>string<
: >
; :˛ ;
Fu :end2 end-bar NIL
string<=
⊲ If foo is lexicographically not equal, greater, not less, less,
or not greater, respectively, then return character number
from beginning of foo where they begin to differ. Otherwise
return NIL.
8 Fu 9 8˛ 9
>string-not-equal > ˛:start1 start-foo 0 >
> Fu
>string-greaterp >
> >
>˛ >
< 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, ignoring case, then return
character number from beginning of foo where they begin
to differ. Otherwise return NIL.
Fu
(string x )
⊲ Convert x (symbol, string, or character) into a string.
˛ ff
Fu ˛:initial-element char
(make-string size ˛˛ )
:element-type type character
⊲ Return string of length size.
8 9
 Fu ff <capitalize= ˛ ff
string ˛:start start 0
( Fu - upcase string ˛˛ )
nstring : ; :end end NIL
downcase
⊲ Return string (not modified or modified, respectively)
with first letter of every word turned into uppercase, letters
all uppercase, or letters all lowercase, respectively.

7
Common Lisp Quick Reference
8 Fu 9
<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.
Fu
(char string i )
Fu
(schar string i )
⊲ Return zero-indexed ith character of string ignor-
ing/obeying, respectively, fill pointer. setfable.
8˛ 9
> ˛: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.
8˛ 9
<˛˛ :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 ff
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.
8˛ 9
<˛˛ :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)
⊲ Return zero-indexed nth element of list. setfable.

8
Common Lisp Quick Reference

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.
 Fu ff
butlast list
( Fu f [num 1 ])
nbutlast list
⊲ Return list excluding last num conses.
 Fu ff
rplaca
( Fu g object)
cons
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 .
8˛ 9
<˛˛ :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
]
(pop place)
Fu Fu
⊲ Set place to (cdr place ), return (car place ).
M
]
(push foo place)
Fu
⊲ Set place to (cons foo place ).
8˛ 9
<˛˛ :test function #’eql =
M
] ˛ :test-not function )
(pushnew foo place
:˛˛ ;
:key function
Fu
⊲ Set place to (adjoin foo place ).
Fu
(append [list ∗ foo])
Fu
f ∗ foo])
(nconc [list
⊲ Return concatenated list. foo can be of any type.
Fu
(revappend list foo)
Fu
f foo)
(nreconc list
⊲ Return concatenated list after reversing order in list.
 Fu ff
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 ff
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 ff
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.
8˛ 9
 Fu ff <˛˛ :test test #’eql =
assoc
( Fu foo alist ˛˛ :test-not test )
rassoc :˛ ;
 Fu ff :key function
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
 ff
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.
8˛ 9
 Fu ff <˛ :test function #’eql =
subst new old tree ˛
( Fu ˛
g :˛˛ :test-not function ;)
nsubst new old tree
:key function
⊲ Make copy of tree with each subtree or leaf matching old
replaced by new .
 Fu ff
subst-if[-not] new test tree
( Fu g [:key function])
nsubst-if[-not] new test tree
⊲ Make copy of tree with each subtree or leaf satisfying test
replaced by new .
8˛ 9
 Fu ff <˛ :test function #’eql =
sublis association-list tree ˛
( Fu ˛
g :˛˛ :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
8 Fu 9 9
>intersection > > >
>
> Fu = >
>
>
>set-difference >
>
>
> Fu a b >
> 8˛ 9
>
>union >
> >
>
< Fu ; = <˛˛ :test function #’eql =
set-exclusive-orff ˛ :test-not function )
( Fu
>
>nintersection > :˛˛ ;
> Fu
> eb >
a >
> :key function
>
>nset-difference ff >
>
>
> Fu >
>
:nunion
> Fu ee
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)
⊲ Return T if array is adjustable/has a fill pointer, respec-
tively.
Fu
(array-in-bounds-p array [subscripts])
⊲ Return T if subscripts are in array ’s bounds.

5.2 Array Functions


 Fu ˆ ˜ff
make-array dimensions :adjustable bool NIL
( Fu
] dimensions
adjust-array array
8˛ 9
> ˛:element-type type T >
>
> ˛ >
>
> ˛
<˛:fill-pointer {num bool } >
=
8 NIL
˛<:initial-element obj )
> ˛ >
>
> ˛ :initial-contents sequence >
>
> ˛
:˛: >
;
:displaced-to array NIL [:displaced-index-offset i 0 ]
⊲ Return fresh, or readjust, respectively, vector or array of
dimensions .
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
^ [result-bit-array
(bit-not 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.
8 Fu 9
>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
^ [num])
(vector-push-extend foo vector
⊲ 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 ff
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 ff
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.
8˛ 9
> ˛: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 ^ test [:key function NIL ])
sequence-b
⊲ Return interleaved sequence of type. Merged sequence
will be sorted if both sequence-a and sequence-b are sorted.
˛ ff
Fu ˛:start start 0
^ foo ˛˛
(fill sequence )
: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).
8˛ 9
> ˛: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 foo s in sequence which satisfy tests.
8˛ 9
˛
 Fu ff >˛:from-end bool NIL >
>
< >
=
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 ff
sort
( Fu ^ test [:key function])
sequence
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
8˛ 9
> ˛:from-end bool NIL >
>
> ˛ >
>
> ˛ :test test #’eql >>
>
 Fu ff <˛˛
> >
=
find ˛ :test-not test
( Fu foo sequence ˛ )
position >
> ˛:start start 0 >
>
>
>˛:end end NIL >
>
>
> >
:˛˛ >
;
:key function
⊲ Return first element in sequence which satisfies test, or
its position relative to the begin of sequence, respectively.
8 Fu 9 8˛ 9
>find-if > > ˛:from-end bool NIL >
>
< Fu >
= <˛˛
> >
=
find-if-not :start start 0
( Fu test sequence ˛˛ )
>
>position-if >
> >
> :end end >
: Fu ; :˛˛ NIL >
;
position-if-not :key function
⊲ Return first element in sequence which satisfies test, or
its position relative to the begin of sequence, respectively.
8˛ 9
> ˛: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.
8˛ 9
> ˛:from-end bool NIL >
>
> ˛ >
>
> ˛ >
>
>
> ˛ :test function #’eql >
>
 Fu ff<>˛ :test-not function > >
=
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.

8 Fu ff 98˛ 9
> ˛:from-end bool NIL >
>remove-if
>
< Fu
>
test sequence>
=
>
> ˛
<˛:start start 0
>
>
=
remove-if-notff ˛
( 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.
8˛ 9
> ˛:from-end bool NIL >
>
> ˛ >
>˛ :test function #’eql >>
 Fu ff>
<˛˛
> >
>
=
remove-duplicates sequence ˛ :test-not function
( Fu ˛ )
^
delete-duplicates sequence >
> ˛:start start 0 >
>
>
>˛:end end NIL >
>
>
> >
:˛˛ >
;
:key function
⊲ Make copy of sequence without duplicates.
8˛ 9
> ˛:from-end bool NIL >
>˛
> >
>
> ˛ :test function #’eql >
>
>
>˛˛
> >
>
 Fu ff><˛ :test-not function > =
substitute new old sequence ˛:start start 0
( Fu ˛ )
^
nsubstitute new old sequence >
> >
>˛˛:end end NIL
>
>
>
>
>
> ˛ >
>
>˛:key function
>
:
>
>
;
˛:count count NIL
⊲ Make copy of sequence with all (or count ) olds replaced
by new .

8 Fu ff 9 8˛ 9
> ˛:from-end bool NIL >
>substitute-if
>
< Fu new test sequence >
>
=
>
> ˛
<˛:start start 0
>
>
=
substitute-if-not ff ˛
( 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 .
8˛ 9
> ˛: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.

8˛ 9
> ˛: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)
⊲ Return 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.

8˛ 9
> ˛:test {Fu Fu Fu Fu
eq eql equal equalp} #’eql >
>
<˛˛ >
=
Fu :size int
(make-hash-table ˛˛ )
>
>˛ :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
d ∗ )∗ formP∗ )
(with-hash-table-iterator (foo hash-table) (declare decl
⊲ 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
n
(defstruct foo (foo
8˛ ( 9
> ˛ :conc-name >
>
> ˛ >
>
>
> ˛ (:conc-name [ \ foo- ])
slot-prefix >
>
>
> ˛ >
>
>˛(
> )∗ >
>
>
> ˛ :constructor >
>
>
> ˛ ˆ ˜ >
>
> ˛
>˛ (:constructor maker\ MAKE-foo [(ord-λ [ )] )
∗ >
>
>
> >
>
>
> ˛( >
>
>˛ :copier
> >
>
>
> ˛ >
>
> ˛ \ COPY-foo ])
>˛ (:copier [copier >
>
>
> >
>
>
> ˛ 8 9∗ >
>
>
> ˛ > d > >
>
<˛ <slot ˛ ff = = o
˛(:include s\truct ˛:type type
d )
˛ d ˛ )
>
> ˛ >
:(slot [init ˛:read-only bool >
d ]); > >

> >
>
>
> ˛8 8 9 >
>
>
> ˛> <list = ˛˛ >
>
>
> ˛>
> :named >
>
>
> ˛>
> (:type vector ) ˛ >
>
>˛<
> : ; ˛(:initial-offset n
b ) >
>
> ˛
>˛ ( d
(vector size) >
>
>
> >
>
>
> ˛>
> \ >
>
>˛>
> > (:print-object [o-printer ]) >
>
>
> ˛>
: >
>
> \ ])
>˛ (:print-function [f-printer >
>
>
> ˛ >
>
>
> ˛ :predicate >
>
>
:˛˛ >
;
\ foo-P ])
(:predicate [p-name
8 9∗
<slot ˛ ff =
d
[doc] ˛:type type
d )
:(slot [init ˛˛ d ]);
:read-only bool
⊲ Define structure type foo together with functions
MAKE-foo, COPY-foo and (unless :type without :named is
used) foo-P; and setfable accessors foo-slot . Instances of
type foo 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 defined in ord-λ whose var s in
turn correspond to slot s. :print-object/:print-function gen-
gF
erate a print-object method for an instance bar of foo calling
(o-printer bar stream) or (f-printer bar stream print-level),
respectively.
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
of the same type with equalp elements; or are hash-tables of
the same size with the same :test function, the same keys
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.
 ff
Fu foo
(fboundp ) ⊲ T if foo is a global function or macro.
(setf foo)

15
Common Lisp Quick Reference

9.2 Variables
M ff
defconstant c form [doc])
d
( M foo
defparameter
⊲ Assign value of form to global constant/dynamic variable
foo.
M ˆ ˜
c form [doc]
(defvar foo d )
⊲ Unless bound already, assign value of form to dynamic
variable foo.
M ff
setf
( M {place form}∗ )
psetf
⊲ Set places to primary values of forms. Return values of
last form /NIL; work sequentially/in parallel, respectively.
 sO ff
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
^ foo)
(set symbol
⊲ 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
] + foo)
(shiftf place
⊲ 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)f ⊲ 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
^ key)
(remprop symbol
M
] key)
(remf place
⊲ 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 ff form
ˆ ∗˜
∗ var ˆ ˜
(var &optional [&rest var ]
(var init NIL [supplied-p] )
8 9∗
ˆ <var
 ff =
&key var ˆ ˜
:( init NIL [supplied-p] );
(:key var )
 ff∗
˜ˆ 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.
8  9
<M foo =
defun d ∗ )∗ [doc]
d formP∗ )
( (setf foo) (ord-λ∗ ) (declare decl
:M ;
lambda
⊲ 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 foo.

16
Common Lisp Quick Reference
sO ff  ff
flet foo \ ∗ )∗ [doc]
d
( sO (( (ord-λ∗ ) (declare local-decl
labels (setf foo)
P d ∗ )∗ formP∗ )
local-form ∗ )∗ ) (declare decl
⊲ 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
sponding local-form . Only for labels, functions foo are
visible inside local-forms . Return values of form s.

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

 ff
Fu function
(apply arg + )
(setf function)
⊲ Return values of function called on args. Last arg must
Fu Fu Fu
be a list. setfable if function is one of aref, bit, and sbit.

Fu
(funcall function arg∗ )
⊲ Return values of function called with arg s.

sO
(multiple-value-call foo form ∗ )
⊲ Call function foo with all the values of each form as its
arguments. Return values returned by foo .

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)
⊲ Return in a list 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)
⊲ Return 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

 ff
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 ∗ ) has the form of either
 list (macro-λff∗
var
([&whole var ] [E ] [E ]
(macro-λ∗ )
8 9∗
<var
 ff =
[&optional var ˆ ˜ ] [E ]
:( init NIL [supplied-p] ) ;
(macro-λ∗ )
 ff ff
&rest var
[ ] [E ]
&body (macro-λ∗ )
8 9∗
>
>var
8 9 >
>
ˆ < =
<var  ff =ˆ ˜
&key [E ]
>(:(:key var
>
: );
init NIL [supplied-p] )> >
;
(macro-λ∗ )
 ff∗
˜ var
[&allow-other-keys] [&aux ] [E ])
(var [init NIL ])
 ff∗
var
or ([&whole var ] [E ] [E ]
(macro-λ∗ )
8 9∗
<var
 ff =
[&optional var ˆ ˜ ] [E ] . 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 ff ff
defmacro foo
( Fu (macro-λ∗ ) (declare
define-compiler-macro (setf foo)
d ∗ )∗ [doc]
decl d formP∗ )
⊲ 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 foo.
M
(define-symbol-macro foo form)
⊲ Define symbol macro foo which on evaluation evaluates
expanded form.
sO
\ ∗ )∗ [doc]
(macrolet ((foo (macro-λ∗ ) (declare local-decl d
P∗ ∗ d ∗ ∗ 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
d ∗ )∗ formP∗ )
(symbol-macrolet ((foo expansion-form)∗ ) (declare decl
⊲ Evaluate forms with locally defined symbol macros foo.
M
(defsetf ( \
function )
\ [doc]
updater d
)
d ∗ )∗ [doc]
(setf-λ∗ ) (s-var ∗ ) (declare decl d formP∗
where defsetf lambda ∗
 list (setf-λ ) has the form ff∗
ˆ var ˆ ˜

(var &optional ˜
(var init NIL [supplied-p] )
8 9∗
ˆ <var
 ff =
[&rest 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). 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 arguments of function and the value(s) to be
stored, respectively; and that returns the value(s) of s-var ∗ .
sO
forms are enclosed in an implicit block named function.
M
d ∗ )∗ [doc]
(define-setf-expander function (macro-λ∗ ) (declare decl d
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 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
 ff∗
var ˆ ˜
˜ d
[&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 ff
when P
( M test foo ∗ )
unless
⊲ Evaluate foos and return their values if test returns T or
NIL, respectively. Return NIL otherwise.
( )  ff
M d∗ )
(key P ˆ otherwise P ˜
(case test ( foo ∗ )∗ ( bar ∗ ) NIL )
d
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 ff ( )
ecase d∗ )
(key P
( M test ( d 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 .
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/1st value, respec-
tively, of form-r .

19
Common Lisp Quick Reference
sO ff ˛ ff∗
let ˛name
( sO ( ˛˛ d ∗ )∗ formP∗ )
) (declare decl
let∗ (name [value NIL ])
⊲ Evaluate forms with names lexically bound (in parallel
or sequentially, respectively) to values. Return values of
forms.
 M ff ˛ ff∗  ff
prog ˛var c ∗
d ∗ )∗ tag
( M ( ˛˛ ) (declare decl )
prog∗ (var [value NIL ]) form
sO
⊲ Evaluate tagbody-like body with var s locally bound (in
parallel or sequentially, respectively) to values. Return NIL
M
or explicitly returned values. Implicitly, the whole form is
sO
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
d ∗ )∗ formP∗ )
(destructuring-bind destruct-λ bar (declare decl
⊲ 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
d ∗ )∗
var ∗ ) values-form (declare decl
(multiple-value-bind (d
P
body-form ∗ )
⊲ Evaluate body-forms 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
c form}∗ )
(tagbody {tag
⊲ Evaluate forms in al lexical environment. tags (symbols
or integers) have lexical scope and dynamic extent, and are
sO
targets for go. Return NIL.
sO
c
(go tag)
sO
⊲ Within the innermost 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 ff  ff∗
do var ˆ d ∗ )∗
˜ ) (stop resultP∗ ) (declare decl
( M (
do∗ (var start [step] )
 ff∗
c
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.
M
d ∗ )∗ {tag
(dotimes (var i [result NIL ]) (declare decl c 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.

20
Common Lisp Quick Reference

M
d ∗ )∗ {tag
(dolist (var list [result NIL ]) (declare decl c 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.
 ff
var-s
{with [d-type] = foo}+
(var-s ∗ )
 ff
var-p
{and ∗ [d-type] = bar }∗
(var-p )
where destructuring type specifier  ff o has the form
d-type
n ˘ type ¯
fixnum float T NIL of-type
(type ∗ )
⊲ Initialize (possibly trees of) local variables var-s se-
quentially and var-p in parallel.
 ff  ff
˘ 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 in the first iteration 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}
var
package ∗package∗ ]
⊲ Bind var successively to the accessible sym-
bols, or the present symbols, or the external
symbols respectively, of package.
{do doing} form +
⊲ Evaluate forms in every iteration.
{if when unless} test i-clause {and j-clause}∗ [else
k-clause {and l-clause}∗ ] [end]
⊲ If test returns T, T, or NIL, respectively, evaluate
i-clause and j-clauses; otherwise, evaluate k-clause and
l-clauses.
it ⊲ Inside i-clause or k-clause: value of test .
return {form it}
⊲ Return immediately, skipping any finally parts, with
values of form or it.

21
8 ff 9∗

22

Figure 1: Loop Facility,

Common Lisp Quick Reference


> >
8  ff  ff 9∗ >
>
>
do
form + >
>
>
> var var ∗ > >
> doing 9 >
>
>
>with ∗ [d-type] = foo {and ∗ [d-type] = bar } >
> >
> >
>
>
> (var ) (var ) >
> >
> if = >
>
>
> 8 8 9 9 >
> >
> >
>
>
>  ff 9 >
> >
> when test Ci {and Cj } [else Ck {and Cl } ][end] >
∗ ∗ >
> < upto = > > >

Overview.
> >
>ˆ upfrom ˜ ˆ ˜> >
> > > ; >
>
> >
> >
> >
> >
> >
> unless  >
>
>
> >
> start 0 to form > > >
> >
> >
> >
>
>
> >
> from : ; >
> >
> >
> >
> form >
>
>
> >
>  ff below >
> >
> >
> >
> return >
>
>
> >
> = >
> >
> >
> it 9 >
>
>
> >
> downto >
> >
> >
> >
>
>
> >
>from start form [by step 1 ] >
> >
> >
> collect[ing] =  ff >
>
>
> >
> above 8 9 >
> >
> >
> >
> form >
>
>
> >
> >
> >
> >
> >
> append[ing] [into list] >
>
>
> >
> ˆ < downto = ˜ > > >
> >
> >
> ; it >
>
>
> >
> >
> >
> >
> >
> nconc[ing] >
>
>
> >downfrom start
> to form ; > >
> >
> >
> 9 >
>
>
> >
> : ; >
> >
> >
> count[ing] > >
>
>
> >
> ff above >
> >
> >
> > >
>
>
< ff  ff >
> >
> >
= >
< sum[ming] > > >
=
<in list [by function ] = n o∗ >
= ff
(loop [named n NIL ] for var
∗ [d-type] on
#’cdr
and Fi > > maximize form )
>
>as (var ) > > > > [into num] [type] >
>
> > > > > maximizing> > it >
>
>
> >= foo [then bar foo ]
>
>
>
>
>
>
>
>
>
>
> > >
>
>
>
> >
>across vector >
> >
> >
> minimize > >
; >
>
>
> > ff  ff > >
> >
> >
>
>
>
>
>
8
hash-key of
>
>
> >
> >
> minimizing C0 >
>
>
>
> >
> >
> hash [using (hash-value v )]>
> >
> >
> >
>
>
> >
> >
>hash-keys in >
> >
> >
> ff >
>
>
> >
> >
> ff  ff >
> >
> >
> initially >
>
>
> >
>  ff >
<hash-value of >
> >
> >
> form + >
>
>
> >
> the hash [using (hash-key k )]>
> >
> >
> finally >
>
>
> >
> being hash-values in >
> >
> >
> >
>
>
> >
> each > 9 >
> >
> >
> repeat num >
>
>
> >
> >
>symbol[s] =ˆ  ff >
> >
> >
> 9 >
>
>
> >
> >
> of ˜>
> >
> >
> while > >
>
>
> >
> >
> present-symbol[s] package var >
> >
> >
> > >
>
>
> >
: : ; in ∗package∗ >
; >
> >
> until > = >
>
>
> external-symbol[s] F0 >
> >
> >
>
>
> >
> >
> always test >
>
>
> >
> > >
: ; >>
> never >
>
>
>
>
>
T1 >
> ; >
>
>
: thereis T2 >
;
Common Lisp Quick Reference

{collect collecting} {form it} [into list]


⊲ Collect values of form or it into list. If no list is
given, collect into an anonymous list which is returned
after termination.
{append appending nconc nconcing} {form it} [into list]
⊲ Concatenate values of form or it, which should be
Fu Fu
lists, into list by the means of append or nconc, respec-
tively. If no list is given, collect into an anonymous list
which is returned after termination.
{count counting} {form it} [into n] [type]
⊲ Count the number of times the value of form or of it
is T. If no n is given, count into an anonymous variable
which is returned after termination.
{sum summing} {form it} [into sum] [type]
⊲ Calculate the sum of the primary values of form or of
it. If no sum is given, sum into an anonymous variable
which is returned after termination.
{maximize maximizing minimize minimizing} {form it} [into
max-min] [type]
⊲ Determine the maximum or minimum, respectively,
of the primary values of form or of it. If no max-min
is given, use an anonymous variable which is returned
after termination.
{initially finally} form +
⊲ Evaluate forms before begin, or after end, respec-
tively, of iterations.
repeat num
M
⊲ Terminate loop after num iterations; num is evalu-
ated once.
{while until} test
⊲ Continue iteration until test returns NIL or T, respec-
tively.
{always never} test
M
⊲ Terminate loop returning NIL and skipping any finally
parts as soon as test is NIL or T, respectively. Otherwise
M
continue loop with its default return value set to T.
thereis test
M
⊲ Terminate loop when test is T and return value of test,
M
skipping any finally parts. Otherwise continue loop with
its default return value set to NIL.
M
(loop-finish)
M
⊲ Terminate loop immediately executing any finally
clauses and returning any accumulated results.

10 CLOS
10.1 Classes
Fu
(slot-exists-p foo bar ) ⊲ T if foo has a slot bar .
Fu
(slot-boundp instance slot) ⊲ T if slot in instance is bound.
M
(defclass foo (superclass ∗ standard-object )
8 9∗
> slot
>
> 8˛ ∗ 9> >
>
>
> > ˛ {:reader reader } ff > >
>
>
> >
> ˛ >
> >
>
>
> > ˛
>˛{:writer writer ∗ >
> >
>
>
> >
> } >
> >
>
>
> >
> ˛ (setf writer ) >
> >
>
>
> >
> ˛ ∗ >
> >
>
< >˛{:accessor accessor
>  }ff >
> =
<˛ =
( ˛ :instance )
>
> (slot ˛ :allocation :instance )>
>
>
> >
> ˛ :class >
> >
>
>
> >
> ˛ >
> >
>
> >˛{:initarg :initarg-name}∗
> >>
> >
>
>
> >
> ˛ >
> >
>
>
> >
>˛˛ :initform form >
>> >
>
> >
> >
> >
>
>
: :˛˛:type type
> >
;> ;
8˛ :documentation slot-doc 9
<˛˛(:default-initargs {name value}∗ )=
˛(:documentation class-doc) )
:˛˛ ;
(:metaclass name standard-class )
⊲ Define, as a subclass of superclass es, class foo. In a new
instance i , a slot ’s value defaults to form unless set via
:initarg-name; it is readable via (reader i) or (accessor
i), and writeable via (writer i value) or (setf (accessor
i) value). With :allocation :class, slot is shared by all in-
stances of class foo.

23
Common Lisp Quick Reference

Fu ˆ ˜
(find-class symbol errorp T [environment ] )
⊲ Return class named symbol . setfable.
gF
(make-instance class {:initarg value}∗ other-keyarg ∗ )
⊲ Make new instance of class .
gF
(reinitialize-instance instance {:initarg value}∗ other-keyarg ∗ )
⊲ Change local slots of instance according to initargs.
Fu
(slot-value foo slot) ⊲ Return value of slot in foo . setfable.
Fu
(slot-makunbound instance slot )
⊲ Make slot in instance unbound.
M ff
d (d
with-slots ({slot d ∗)
var slot)}
( M d ∗ )∗
instance (declare decl
with-accessors ((d \ ) )
var accessor ∗
P∗
form )
⊲ Return values of form s after evaluating them in a lexical
environment with slots of instance visible as setfable slot s
or var s/with accessor s of instance visible as setfable var s.
gF
(class-name class)
gF ⊲ Get/set name of class .
((setf class-name) new-name class)
Fu
(class-of foo) ⊲ Class foo is a direct instance of.

gF
^ new-class {:initarg value}∗ other-keyarg ∗ )
(change-class instance
⊲ Change class of instance to new-class.
gF
(make-instances-obsolete class)
⊲ Update instances of class.
 gF ff
initialize-instance (instance)
( gF
update-instance-for-different-class previous current
{:initarg value}∗ other-keyarg ∗ )
⊲ Its primary method sets slots on behalf of
gF gF gF
make-instance/of change-class by means of shared-initialize.
gF
(update-instance-for-redefined-class instances added-slots
discarded-slots property-list {:initarg value}∗
other-keyarg ∗ )
⊲ Its primary method sets slots on behalf of
gF gF
make-instances-obsolete by means of shared-initialize.
gF
(allocate-instance class {:initarg value}∗ other-keyarg ∗ )
⊲ Return uninitialized instance of class. Called by
gF
make-instance.
 ff
gF slots
(shared-initialize instance {:initarg value}∗ other-keyarg ∗ )
T
⊲ Fill instance’s slots using initargs and :initform forms.
8 9
>
>setf >
>
< =
gF slot-boundp
(slot-missing class object slot [value])
>slot-makunbound>
>
: >
;
slot-value
⊲ Called in case of attempted access to missing slot . Its
primary method signals error.
gF
(slot-unbound class instance slot )
Fu
⊲ Called by slot-value in case of unbound slot . Its primary
method signals unbound-slot.

10.2 Generic Functions


Fu
(next-method-p)
⊲ T if enclosing method has a next method.
 ff  ff∗
M foo ˆ var ˜
(defgeneric (required-var ∗ &optional
(setf foo) (var )
 ff∗
ˆ ˜ˆ var
&rest var &key
(var (:key var ))
˜
[&allow-other-keys] )

24
Common Lisp Quick Reference
8˛ 9
˛ required-var + )
>˛(:argument-precedence-order
>
> +
>
>
>
>
> ˛(declare (optimize arg ) ) ∗ >
>
>
> ˛ >
>
> ˛ \
<˛(:documentation string) >
=
˛(:generic-function-class class ) )
> ˛ standard-generic-function
>
>˛˛(:method-class class standard-method )
> >
>
>
> >
>
>
> ˛ ∗ >
>
>˛(:method-combination c-type standard c-arg )
: >
;
˛(:method defmethod-args)∗
⊲ Define generic function foo. defmethod-args resemble
M
those of defmethod. For c-type see section 10.3.
 ff
Fu foo
(ensure-generic-function
(setf foo)
8˛ 9
> ˛:argument-precedence-order required-var + >
>˛˛:declare (optimize arg ∗ )+
> >
>
>
> >
>
>
> ˛ >
>
>
> ˛:documentation string >
>
<˛ =
˛:generic-function-class class
˛ )
>
> ˛:method-class class >
>

> ∗ >
>
>
> ˛:method-combination c-type c-arg >
>
>
> ˛ >
>
:˛˛:lambda-list lambda-list
> >
;
:environment environment
⊲ Define or modify generic function foo.
:generic-function-class and :lambda-list have to be compat-
ible with a pre-existing generic function or with existing
methods, respectively. Changes to :method-class do not
propagate to existing methods. For c-type see section 10.3.
8 9
 ff > > :before > >
< =
M foo :after
(defmethod [ primary method ]
(setf foo) > > :around >
>
: ∗;
qualifier
8 9∗
<var  ff= ˆ
( class &optional
:(spec-var );
(eql bar )
 ff∗
var ˆ ˜ ˆ
˜ [&rest var ] &key
(var init [supplied-p] )
8 9∗
<var ff = ˜
var ˆ ˜ [&allow-other-keys]
:( init [supplied-p] );
(:key var )
 ff∗ (˛˛ )
ˆ var ˜ ˛(declare decl d ∗ )∗ P
&aux ) ˛d form ∗ )
(var [init]) ˛doc
⊲ Define new method for generic function foo. spec-var s
specialize to either being of class or being eql bar , re-
spectively. On invocation, var s and spec-var s of the new
method act like parameters of a function with body form ∗ .
sO
forms are enclosed in an implicit block foo. Applicable
qualifier s depend on the method-combination type; see sec-
tion 10.3.
 gF ff
add-method
( gF generic-function method )
remove-method
⊲ Add (if necessary) or remove (if any) method to/from
generic-function.
gF
(find-method generic-function qualifiers specializers [error T ])
⊲ Return suitable method, or signal error.
gF
(compute-applicable-methods generic-function args)
⊲ List of methods suitable for args, most specific first.
Fu
(call-next-method arg ∗ current args )
⊲ From within a method, call next method with args; re-
turn its values.
gF
(no-applicable-method generic-function arg ∗ )
⊲ Called on invocation of generic-function on args if there
is no applicable method. Default method signals error.
 Fu ff
invalid-method-error method
( Fu control arg ∗ )
method-combination-error
⊲ Signal error on applicable method with invalid qualifiers,
or on method combination. For control and arg s see format,
p. 34.
gF
(no-next-method generic-function method arg ∗ )
⊲ Called on invocation of call-next-method when there is
no next method. Default method signals error.

25
Common Lisp Quick Reference

gF
(function-keywords method )
⊲ Return list of keyword parameters of method and T if
2
other keys are allowed.
gF
(method-qualifiers method ) ⊲ List of qualifiers of method .

10.3 Method Combination Types


standard
⊲ Evaluate most specific :around method supplying the val-
ues of the generic function. From within this method,
Fu
call-next-method can call less specific :around methods if
there are any. If not, or if there are no :around methods
at all, call all :before methods, most specific first, and the
most specific primary method which supplies the values of
Fu
the calling call-next-method if any, or of the generic func-
tion; and which can call less specific primary methods via
Fu
call-next-method. After its return, call all :after methods,
least specific first.

and or append list nconc progn max min +


⊲ Simple built-in method-combination types; have the
same usage as the c-types defined by the short form of
M
define-method-combination.
M
(define-method-combination
8˛ c-type 9
<˛˛:documentation s\ tring =
˛:identity-with-one-argument bool NIL )
:˛˛ ;
:operator operator c-type
⊲ Short Form. Define new method-combination c-type. In
a generic function using c-type, evaluate most specific
:around method supplying the values of the generic func-
Fu
tion. From within this method, call-next-method can
call less specific :around methods if there are any. If
not, or if there are no :around methods at all, have
generic function applied to gen-arg ∗ return with the
values of (c-type {primary-method gen-arg ∗ }∗ ), leftmost
M
primary-method being the most specific. In defmethod, pri-
mary methods are denoted by the qualifier c-type.
M ∗
(define-method-combination
8 9 c-type (ord-λ ) ((group
<∗ ˆ ˜ =
(qualifier ∗ ∗ )
: ;
8˛predicate 9
˛
>˛:description
>
<  control ff >
>
=
˛
˛:order :most-specific-first :most-specific-first )∗ )
> ˛ :most-specific-last >

: >
;
˛:required bool
8˛ ∗ 9
> ˛(:arguments method-combination-λ )>
>
<˛˛(:generic-function symbol ) >
=
P
˛ body ∗ )
> d )
˛(declare decl ∗ ∗
>
>
:˛˛d >
;
doc
⊲ Long Form. Define new method-combination c-type. A
call to a generic function using c-type will be equivalent to
a call to the forms returned by body ∗ with ord-λ∗ bound to
M
c-arg ∗ (cf. defgeneric), with symbol bound to the generic
function, with method-combination-λ∗ bound to the argu-
ments of the generic function, and with groups bound to
lists of methods. An applicable method becomes a mem-
ber of the leftmost group whose predicate or qualifier s
M
match. Methods can be called via call-method. Lambda
lists (ord-λ∗ ) and (method-combination-λ∗ ) according to
ord-λ on p. 16, the latter enhanced by an optional &whole
argument.
( ) ( )∗
M \
method \
ˆ next-method ˜
(call-method ( ) )
M
[)
(make-method form
M
[)
(make-method form
⊲ From within an effective method form, call method with
the arguments of the generic function and with information
about its next-methods; return its values.

26
Common Lisp Quick Reference

11 Conditions and Errors


M
(define-condition foo (parent-type ∗ condition )
8 9∗
> slot
>
> 8˛ ∗ 9>>
>
>
> >˛˛ {:reader reader
 } ff > >
>
>
> >
> >
> >
>
>
> >
> ˛ writer ∗ >
> >
>
>
> >
> ˛{:writer } >
> >
>
>
> >
>˛˛ (setf writer ) >
> >
>
>
> >
> ∗ >
> >
>
< >
> ˛ {:accessor accessor
 } ff >
> =
<˛ =
( ˛ :instance )
>
> (slot ˛:allocation :instance )>
>
>
> >
>˛˛ :class >
> >
>
>
> >
> >
> >
>
>
> >
> ˛{:initarg :initarg-name}∗ >
> >
>
>
> >
> ˛ >
> >
>
>
> >
> ˛:initform form >
> >
>
>
> >
> ˛ >
> >
>
>
: >
:˛˛ :type type >
;>;
8˛ :documentation slot-doc 9
> ˛(:default-initargs {name value} )> ∗
<˛˛
> >
=
˛(:documentation
 condition-doc)
ff )
> ˛ string >
:˛˛(:report
> ) >
;
report-function
⊲ Define, as a subtype of parent-types, condition type foo.
In a new condition, a slot ’s value defaults to form unless set
via :initarg-name; it is readable via (reader i) or (accessor
i), and writeable via (writer i value) or (setf (accessor i)
value). With :allocation :class, slot is shared by all condi-
tions of type foo. A condition is reported by string or by
report-function of arguments condition and stream.
Fu
(make-condition type {:initarg value}∗ )
⊲ Return new condition of type .
8 Fu 9 8 9
<signal
Fu
= <condition =
( warn type {:initarg-name value}∗ )
: Fu ;: ;
error control arg ∗
⊲ Unless handled, signal as condition, warning or error,
respectively, condition or a new condition of type or,
Fu
with format control and arg s (see p. 34), simple-condition,
Fu
simple-warning, or simple-error, respectively. From signal
Fu
and warn, return NIL.
8 9
<condition continue-arg ∗ =
Fu
(cerror continue-control type {:initarg-name value}∗ )
: ;
control arg ∗
⊲ Unless handled, signal as correctable error condition or a
Fu
new condition of type or, with format control and arg s (see
Fu
p. 34), simple-error. In the debugger, use format arguments
continue-control and continue-args to tag the continue op-
tion. Return NIL.
M P
(ignore-errors form ∗ )
⊲ Return values of form s or, in case of errors, NIL and the
condition.
2
Fu
(invoke-debugger condition )
⊲ Invoke debugger with condition.
8 9
M ˆ <condition continue-arg ∗ =˜
∗ ∗
(assert test (place ) [ type {:initarg-name value} ] )
: ;
control arg ∗
⊲ If test, which may depend on places, returns NIL, signal
as correctable error condition or a new condition of type or,
Fu
with format control and args (see p. 34), error. When using
the debugger’s continue option, places can be altered before
re-evaluation of test. Return NIL.
M
d ∗ )∗ condition-form ∗ )∗
(handler-case test (type ([var ]) (declare decl
P

P
∗ d
[(:no-error (ord-λ ) (declare decl )∗ form ∗ )])

⊲ If, on evaluation of test, a condition of type is signalled,


evaluate matching condition-forms with var bound to the
condition, and return their values. Without a condition,
bind ord-λs to values of test and return values of form s or,
without a :no-error clause, return values of test . See p. 16
for (ord-λ∗ ).
M P
(handler-bind ((condition-type handler-function)∗ ) form ∗ )
⊲ Return values of form s after evaluating them with
condition-types dynamically bound to their respective
handler-functions of argument condition.

27
Common Lisp Quick Reference
 ff
M restart P
(with-simple-restart ( control arg ∗ ) form ∗ )
NIL
⊲ Return values of form s unless restart is called during
Fu
their evaluation. In this case, describe restart using format
control and args (see p. 34) and return NIL and T.
2
8˛ 9
> ˛:interactive arg-function >
<˛˛
>  >
M report-function =
(restart-case form (foo (ord-λ∗ ) ˛˛:report
>
> string "foo" >
:˛˛ >
;
:test test-function T
d ∗ )∗ restart-form ∗ )∗ )
(declare decl
P

⊲ Evaluate form with dynamically established restarts foo.


Return values of form or, if by (invoke-restarts foo arg ∗ )
one restart foo is called, use string or report-function (of
a stream) to print a description of restart foo and return
the values of its restart-form s. arg-function supplies ap-
propriate args if foo is called by invoke-restart-interactively.
If (test-function condition ) returns T, foo is made visible
under condition . For (ord-λ∗ ) see p. 16.
 ff
M \
restart
(restart-bind (( restart-function
8˛ NIL 9
<˛˛:interactive-function function =
P
˛:report-function function )∗ ) form ∗ )
:˛˛ ;
:test-function function
⊲ Return values of form s evaluated with restart s dynami-
cally bound to restart-functions.
Fu
(invoke-restart restart arg ∗ )
Fu
(invoke-restart-interactively restart )
⊲ Call function associated with restart with arguments
given or prompted for, respectively. If restart function re-
turns, return its values.
 Fu ff
compute-restarts
( Fu [condition])
find-restart name
⊲ Return list of all restarts, or innermost restart name,
respectively, out of those either associated with condition
or un-associated at all; or, without condition , out of all
restarts. Return NIL if search is unsuccessful.
Fu
(restart-name restart) ⊲ Name of restart .
8 Fu 9
>abort >
>
> Fu >
>
<muffle-warning
Fu
=
( continue [condition NIL ])
>
> Fu >
:store-value
> value>
>
;
Fu
use-value value
⊲ Transfer control to innermost applicable restart with
same name (i.e. abort, . . . , continue . . . ) out of those
either associated with condition or un-associated at all; or,
without condition , out of all restarts. If no restart is found,
Fu Fu
signal control-error for abort and muffle-warning, or return
NIL for the rest.
M P
(with-condition-restarts condition restarts form ∗ )
⊲ Evaluate forms with restarts dynamically associated
with condition. Return values of form s.
Fu
(arithmetic-error-operation condition)
Fu
(arithmetic-error-operands condition)
⊲ List of function or of its operands respectively, used in
the operation which caused condition .
Fu
(cell-error-name condition )
⊲ Name of cell which caused condition.
Fu
(unbound-slot-instance condition)
⊲ Instance with unbound slot which caused condition .
Fu
(print-not-readable-object condition)
⊲ The object not readably printable under condition.
Fu
(package-error-package condition)
Fu
(file-error-pathname condition )
Fu
(stream-error-stream condition )
⊲ Package, path, or stream, respectively, which caused the
condition of indicated type.

28
Common Lisp Quick Reference

T condition
warning style-warning
simple-condition† simple-warning

simple-condition
serious-condition
error
simple-condition† simple-error
parse-error; program-error; control-error

type-error simple-condition† simple-type-error

cell-error unbound-variable; unbound-slot;


undefined-function

stream-error end-of-file
parse-error† reader-error

package-error; file-error; print-not-readable


arithmetic-error
division-by-zero; floating-point-inexact;
floating-point-invalid-operation;
floating-point-overflow; floating-point-underflow

storage-condition

For supertypes of this type look for the instance without a † .

Figure 2: Condition Types.

Fu
(type-error-datum condition)
Fu
(type-error-expected-type condition)
⊲ Object which caused condition of type type-error, or its
expected type, respectively.
Fu
(simple-condition-format-control condition)
Fu
(simple-condition-format-arguments condition )
Fu Fu
⊲ Return format control or list of format arguments, re-
spectively, of condition .
var
∗break-on-signals∗ NIL
⊲ Condition type debugger is to be invoked on.
var
∗debugger-hook∗ NIL
⊲ Function of condition and function itself. Called before
debugger.

12 Input/Output
12.1 Predicates
Fu
(streamp foo)
Fu
(pathnamep foo) ⊲ T if foo is of indicated type.
Fu
(readtablep foo)
Fu
(input-stream-p stream)
Fu
(output-stream-p stream)
Fu
(interactive-stream-p stream)
Fu
(open-stream-p stream)
⊲ Return T if stream is for input, for output, interactive, or
open, respectively.
Fu
(pathname-match-p path wildcard )
⊲ T if path matches wildcard .
Fu ˆ
(wild-pathname-p path {:host :device :directory :name :type
˜
:version NIL} )
⊲ Return T if indicated component in path is wildcard. (NIL
indicates any component.)

29
Common Lisp Quick Reference

12.2 Reader
 Fu ff
y-or-n-p
( Fu [control arg ∗ ])
yes-or-no-p
⊲ Ask user a question and return T or NIL depending on
Fu
their answer. See p. 34, format, for control and args.
M P
(with-standard-io-syntax form ∗ )
⊲ Evaluate forms with standard behaviour of reader and
printer. Return values of form s.
 Fu ff
read ˆ ˆ
( Fu ^ ∗standard-input∗
stream var eof-err T
read-preserving-whitespace
˜˜
[eof-val NIL [recursive NIL ]] )
⊲ Read printed representation of object.
Fu ˆ ˆ
(read-from-string
8˛ string eof-error T eof-val
9 NIL
˛
ˆ<˛:start start 0 =˜˜˜
˛:end end NIL )
:˛˛ ;
:preserve-whitespace bool NIL
⊲ Return object read from string and zero-indexed position
2
of next character.
Fu ˆ ˜
^ ∗standard-input∗
(read-delimited-list char stream var [recursive NIL ] )
⊲ Continue reading until encountering char . Return list of
objects read. Signal error if no char is found in stream.
Fu ˆ ˆ
^ ∗standard-input∗
(read-char stream var eof-err T [eof-val NIL
˜˜
[recursive NIL ]] )
⊲ Return next character from stream.
Fu ˆ ˆ
^ ∗standard-input∗
(read-char-no-hang stream var eof-error T [eof-val NIL
˜˜
[recursive NIL ]] )
⊲ Next character from stream or NIL if none is available.
Fu ˆ ˆ ˆ
(peek-char mode NIL stream^ ∗standard-input∗
var eof-error T [eof-val NIL
˜˜˜
[recursive NIL ]] )
⊲ Next, or if mode is T, next non-whitespace character,
or if mode is a character, next instance of it, from stream
without removing it there.
Fu
^ ∗standard-input∗
(unread-char character [stream var ])
Fu
⊲ Put last read-chared character back into stream; return
NIL.
Fu ˆ ˜
^ eof-err T [eof-val NIL ] )
(read-byte stream
⊲ Read next byte from binary stream.
Fu ˆ ˆ
^ ∗standard-input∗
(read-line stream var eof-err T [eof-val NIL
˜˜
[recursive NIL ]] )
⊲ Return a line of text from stream and T if line has been
2
ended by end of file.
Fu
^ stream
(read-sequence sequence ^ [:start start 0 ][:end end NIL ])
⊲ Replace elements of sequence between start and end with
elements from stream. Return index of sequence’s first un-
modified element.
Fu
(readtable-case readtable ) :upcase
⊲ Case sensitivity attribute (one of :upcase, :downcase,
:preserve, :invert) of readtable. setfable.
ˆ ˜
Fu
(copy-readtable from-readtable ∗readtable∗
var ^
[to-readtable NIL ] )
⊲ Return copy of from-readtable .
ˆ
Fu
^ ∗readtable∗
(set-syntax-from-char to-char from-char to-readtable var
˜
[from-readtable standard readtable ] )
⊲ Copy syntax of from-char to to-readtable. Return T.
var
∗readtable∗ ⊲ Current readtable.
var
∗read-base∗ 10 ⊲ Radix for reading integers and ratios.
var
∗read-default-float-format∗ single-float
⊲ Floating point format to use when not indicated in the
number read.

30
Common Lisp Quick Reference

var
∗read-suppress∗ NIL
⊲ If T, reader is syntactically more tolerant.
Fu ˆ ˜
(set-macro-character char function non-term-p NIL [rt e ∗readtable∗
var ] )
⊲ Make char a macro character associated with function.
Return T.
Fu
(get-macro-character char [rt ∗readtable∗
var ])
⊲ Reader macro function associated with char , and T if
2
char is a non-terminating macro character.
Fu ˆ
(make-dispatch-macro-character char non-term-p NIL
˜
[rt ∗readtable∗
var ] )
⊲ Make char a dispatching macro character. Return T.
Fu
(set-dispatch-macro-character char sub-char function
e ∗readtable∗
[rt var ])
⊲ Make function a dispatch function of char followed by
sub-char . Return T.
Fu
(get-dispatch-macro-character char sub-char [rt ∗readtable∗
var ])
⊲ Dispatch function associated with char followed by
sub-char .

12.3 Macro Characters and Escapes


#| multi-line-comment ∗ |#
; one-line-comment ∗
⊲ Comments. There are conventions:

;;;; title ⊲ Short title for a block of code.


;;; intro ⊲ Description before a block of code.
;; state ⊲ State of program or of following code.
; explanation ⊲ Regarding line on which it appears.

( ⊲ Initiate reading of a list.

” ⊲ Begin and end of a string.


sO
’foo ⊲ (quote foo); foo unevaluated

`([foo] [,bar ] [,@baz ] [,.]


quux ] [bing])
sO
⊲ Backquote. quote foo and bing; evaluate bar and splice
the lists baz and quux into their elements. When nested,
outermost commas inside the innermost backquote expres-
sion belong to this backquote.
Fu
#\c ⊲ (character "c"), the character c.

#B; #O; #X; #nR ⊲ Number of radix 2, 8, 16, or n.


Fu
#C(a b) ⊲ (complex a b), the complex number a + bi.
sO
#’foo ⊲ (function foo); the function named foo.

#nAsequence ⊲ n-dimensional array.

#[n](foo ∗ )
⊲ Vector of some (or n) foos filled with last foo if necessary.

#[n]∗b ∗
⊲ Bit vector of some (or n) bs filled with last b if necessary.

#S(type {slot value}∗ ) ⊲ Structure of type.

#Pstring ⊲ A pathname.

#:foo ⊲ Uninterned symbol foo.

#.form ⊲ Read-time value of form .


var
∗read-eval∗ T ⊲ If NIL, a reader-error is signalled by #..

#int= foo ⊲ Give foo the label int.

#int# ⊲ Object labelled int.

#< ⊲ Have the reader signal reader-error.

31
Common Lisp Quick Reference

#+feature when-feature
#–feature unless-feature
⊲ Means when-feature if feature is T, means unless-feature
var
if feature is NIL. feature is a symbol from ∗features∗, or

({and or} feature ), or (not feature).
var
∗features∗
⊲ List of symbols denoting implementation-dependent fea-
tures.
|c ∗ |; \c
⊲ Treat arbitrary character(s) c as alphabetic preserving
case.

12.4 Printer
8 Fu 9
>
>prin1 >
< Fu > =
print ^ ∗standard-output∗
( Fu foo [stream var ])
>
>pprint>
: Fu > ;
princ
Fu Fu
⊲ Print foo to stream readably, readably between a newline
Fu
and a space, readably after a newline, or human-readably
Fu Fu
without any extra characters, respectively. prin1, print and
Fu
princ return foo.
Fu
(prin1-to-string foo)
Fu
(princ-to-string foo)
Fu
⊲ Print foo to string readably or human-readably, respec-
tively.
gF
^
(print-object object stream)
⊲ Print object to stream. Called by the Lisp printer.
˛ ff
˛
M
^ ˛:type bool NIL
(print-unreadable-object (foo stream
P∗
˛:identity bool NIL ) form )
⊲ Enclosed in #< and >, print foo by means of forms to
stream. Return NIL.
Fu
^ ∗standard-output∗
(terpri [stream var ])
⊲ Output a newline to stream. Return NIL.
Fu
^ ∗standard-output∗
(fresh-line) [stream var ]
⊲ Output a newline to stream and return T unless stream
is already at the start of a line.
Fu
^ ∗standard-output∗
(write-char char [stream var ])
⊲ Output char to stream.
 Fu ff ˛ ff
write-string ˆ ˆ ˛:start start 0 ˜˜
( Fu ^ ∗standard-output∗
string stream var ˛
˛:end end NIL )
write-line
⊲ Write string to stream without/with a trailing newline.
Fu
^
(write-byte byte stream) ⊲ Write byte to binary stream.
˛ ff
˛
Fu
^ ˛:start start 0 )
(write-sequence sequence stream ˛:end end NIL
⊲ Write elements of sequence to stream.
8˛ 9
> ˛:array bool >
>
>˛˛:base radix >
>
>
> >
>
>
> ˛ 8 >
>
>
> ˛ <:upcase >
>
>
> ˛ >
>
>˛:case :downcase
> >
>
>
>˛˛ : >
>
>
> :capitalize >
>
>
> ˛ >
>
>˛:circle bool
> >
>
>
> ˛ >
>
>
>˛˛ :escape bool >
>
>
> >
>
>
> ˛ :gensym bool >
>
 Fu ff >˛
> >
>
<˛:length {int NIL} =
write ˛
( Fu foo ˛:level {int NIL} )
write-to-string >
> ˛ >
>
>
> ˛:lines {int NIL} >
>

> >
>
>
>˛˛:miser-width {int NIL} >
>
>
> >
>
>
> ˛ :pprint-dispatch dispatch-table >
>

> >
>
>
> ˛:pretty bool >
>
>
>˛˛ >
>
>
> :radix bool >
>
>
> ˛ >
>
>
> ˛:readably bool >
>

> >
>
>
> ˛ >
>
>
>˛˛ :right-margin {int NIL} >
>
>
:˛:stream stream >
^ ∗standard-output∗ ;
var

32
Common Lisp Quick Reference

⊲ Print foo to stream and return foo, or print foo into


string, respectively, after dynamically setting printer vari-
ables corresponding to keyword parameters (∗print-bar ∗ be-
Fu
coming :bar ). (:stream keyword with write only.)
Fu ˆ ˜
^ foo parenthesis T [noop] )
(pprint-fill stream
Fu ˆ ˜
^ foo parenthesis T [noop [n 16 ]] )
(pprint-tabular stream
Fu ˆ ˜
^ foo parenthesis T [noop] )
(pprint-linear stream
⊲ Print foo to stream. If foo is a list, print as many elements
per line as possible; do the same in a table with a column
width of n ems; or print either all elements on one line or
each on its own line, respectively. Return NIL. Usable with
Fu
format directive ˜//.
8˛ ff9
M
<˛˛ :prefix string =
^ list ˛˛ :per-line-prefix string
(pprint-logical-block (stream )
:˛ ;
:suffix string ""
d ∗ )∗ formP∗ )
(declare decl
⊲ Evaluate forms, which should print list, with stream lo-
cally bound to a pretty printing stream which outputs to
the original stream. If list is in fact not a list, it is printed
Fu
by write. Return NIL.
M
(pprint-pop)
⊲ Take next element off list. If there is no remaining
var var
tail of list, or ∗print-length∗ or ∗print-circle∗ indicate
printing should end, send element together with an ap-
propriate indicator to stream.
8 9
>:line
> >
>
< =
Fu :line-relative ^ ∗standard-output∗
(pprint-tab c i [stream var ])
>
> :section >
>
: ;
:section-relative
⊲ Move cursor forward to column number c + ki, k ≥ 0
being as small as possible.
 ff
Fu :block ˆ ˜
(pprint-indent ^ ∗standard-output∗
n stream var )
:current
⊲ Specify indentation for innermost logical block rel-
ative to leftmost position/to current position. Return
NIL.
M
(pprint-exit-if-list-exhausted)
⊲ If list is empty, terminate logical block. Return NIL
otherwise.
8 9
>
>:linear >
>
< =ˆ ˜
Fu :fill ^ ∗standard-output∗
(pprint-newline stream var )
>
>:miser >
>
: ;
:mandatory
⊲ Print a conditional newline if stream is a pretty printing
stream. Return NIL.
var Fu
∗print-array∗ ⊲ If T, print arrays readably.
var
∗print-base∗ 10 ⊲ Radix for printing rationals, from 2 to 36.
var
∗print-case∗ :upcase
⊲ Print symbol names all uppercase (:upcase), all lowercase
(:downcase), capitalized (:capitalize).
var
∗print-circle∗ NIL
⊲ If T, avoid indefinite recursion while printing circular
structure.
var
∗print-escape∗ T
⊲ If NIL, do not print escape characters and package pre-
fixes.
var
∗print-gensym∗ T
⊲ If T, print #: before uninterned symbols.
var
∗print-length∗ NIL
var
∗print-level∗ NIL
var
∗print-lines∗ NIL
⊲ If integer, restrict printing of objects to that number of
elements per level/to that depth/to that number of lines.
var
∗print-miser-width∗
⊲ Width below which a compact pretty-printing style is
used.

33
Common Lisp Quick Reference

var
∗print-pretty∗ ⊲ If T, print pretty.
var
∗print-radix∗ NIL ⊲ If T, print rationals with a radix indicator.
var
∗print-readably∗ NIL
Fu
⊲ If T, print readably or signal error print-not-readable.
var
∗print-right-margin∗ NIL
⊲ Right margin width in ems while pretty-printing.
Fu ˆ
(set-pprint-dispatch type function priority 0
˜
[table ∗print-pprint-dispatch∗
var ] )
⊲ Install entry comprising function of arguments stream
and object to print; and priority as type into table. If
function is NIL, remove type from table. Return NIL.
Fu
(pprint-dispatch foo [table ∗print-pprint-dispatch∗
var ])
⊲ Return highest priority function associated with type of
foo and T if there was a matching type specifier in table.
2
Fu
(copy-pprint-dispatch [table ∗print-pprint-dispatch∗
var ])
⊲ Return copy of table or, if table is NIL, initial value of
var
∗print-pprint-dispatch∗.
var
∗print-pprint-dispatch∗ ⊲ Current pretty print dispatch table.

12.5 Format
M
\)
(formatter control
⊲ Return function of stream and a &rest argument applying
Fu
format to stream, control , and the &rest argument return-
ing NIL or any excess arguments.
Fu
(format {T NIL out-string out-stream} control arg ∗ )
⊲ Output string control which may contain ˜ directives
possibly taking some args. Alternatively, control can be
M
a function returned by formatter which is then applied to

out-stream and arg . Output to out-string, out-stream or,
var
if first argument is T, to ∗standard-output∗. Return NIL. If
first argument is NIL, return formatted output.

ˆ ˆ ˆ ˜˜˜
˜[min-col 0 ] ,[col-inc 1 ] ,[min-pad 0 ] ,pad-char ’
[:][@]{A S}
⊲ Aesthetic/Standard. Print argument of any type for
consumption by humans/by the reader, respectively.
With :, print NIL as () rather than nil; with @, add
pad-char s on the left rather than on the right.
ˆ ˆ ˆ
[radix
˜ ˆ 10 ] ,[width] ,[pad-char
˜˜˜˜ ’ ] ,[comma-char ’, ]
,comma-interval 3 [:][@]R
⊲ Radix. (With one or more prefix arguments.)
Print argument as number; with :, group digits
comma-interval each; with @, always prepend a sign.
{˜R ˜:R ˜@R ˜@:R}
⊲ Roman. Take argument as number and print it as
English cardinal number, as English ordinal number, as
Roman numeral, or as old Roman numeral, respectively.
ˆ ˆ
˜[width]
ˆ
,[pad-char ’ ] ,[comma-char ’, ]
˜˜˜
,comma-interval 3 [:][@]{D B O X}
⊲ Decimal/Binary/Octal/Hexadecimal. Print integer ar-
gument as number. With : group digits comma-interval
each; with @, always prepend a sign.
ˆ ˆ ˆ
[width]
˜ ˆ ,[dec-digits] ,[shift 0 ] ,[overflow-char ]
˜˜˜˜
,pad-char ’ [@]F
⊲ Fixed-Format Floating-Point. With @, always pre-
pend a sign.
ˆ ˆ ˆ
[width]
˜ ˆ ,[int-digits] ,[exp-digits] ,[scale-factor 1 ]
ˆ ˆ ˜˜˜˜˜˜
,[overflow-char ] ,[pad-char ’ ] ,exp-char
[@]{E G}
⊲ Exponential/General Floating-Point. Print argument
as floating-point number with int-digits before decimal
point and exp-digits in the signed exponent. With ˜G,
choose either ˜E or ˜F. With @, always prepend a sign.

34
Common Lisp Quick Reference

ˆ ˆ ˆ ˜˜˜
˜[dec-digits 2 ] ,[int-digits 1 ] ,[width 0 ] ,pad-char ’
[:][@]$
⊲ Monetary Floating-Point. Print argument as fixed-
format floating-point number. With :, put sign before
any padding; with @, always prepend a sign.
{˜C ˜:C ˜@C ˜@:C}
⊲ Character. Print, spell out, print in #\ syntax, or
tell how to type, respectively, argument as (possibly
non-printing) character.
{˜(text ˜) ˜:(text ˜) ˜@(text ˜) ˜:@(text ˜)}
⊲ Case-Conversion. Convert text to lowercase, convert
first letter of each word to uppercase, capitalize first
word and convert the rest to lowercase, or convert to
uppercase, respectively.
{˜P ˜:P ˜@P ˜:@P}
⊲ Plural. If argument eql 1 print nothing, otherwise
print s; do the same for the previous argument; if ar-
gument eql 1 print y, otherwise print ies; do the same
for the previous argument, respectively.
˜[n 1 ]% ⊲ Newline. Print n newlines.
˜[n 1 ]&
⊲ Fresh-Line. Print n − 1 newlines if output stream is
at the beginning of a line, or n newlines otherwise.
{˜ ˜: ˜@ ˜:@ }
⊲ Conditional Newline. Print a newline like
pprint-newline with argument :linear, :fill, :miser,
or :mandatory, respectively.
˜[:][@]←֓
⊲ Ignored Newline. Ignore newline and following white-
space. With :, ignore only newline; with @, ignore only
following whitespace.
˜[n 1 ]| ⊲ Page. Print n page separators.
˜[n 1 ]˜ ⊲ Tilde. Print n tildes.
ˆ ˆ ˆ ˜˜˜
˜[min-col 0 ] ˆ ,[col-inc 1 ] ,[min-pad 0 ] ˜ ,pad-char ’

[:][@]< nl-text ˜[spare 0 [,width]]:; {text ˜;} text ˜>
⊲ Justification. Justify text produced by texts in a field
of at least min-col columns. With :, right justify; with
@, left justify. If this would leave less than spare char-
acters on the current line, output nl-text first.
ˆ ˜
˜[:][@]< {prefix "" ˜;} {per-line-prefix ˜@;}
ˆ ˜
body ˜;suffix "" ˜:[@]>
⊲ Logical Block. Act like pprint-logical-block using body
M
as format control string on the elements of the list ar-
gument or, with @, on the remaining arguments, which
are extracted by pprint-pop. With :, prefix and suffix
default to ( and ). When closed by ˜:@>, spaces in
body are replaced with conditional newlines.
{˜[n 0 ]i ˜[n 0 ]:i}
⊲ Indent. Set indentation to n relative to leftmost/to
current position.
˜[c 1 ] [,i 1 ] [:][@]T
⊲ Tabulate. Move cursor forward to column number
c+ki, k ≥ 0 being as small as possible. With :, calculate
column numbers relative to the immediately enclosing
section. With @, move to column number c0 + c + ki
where c0 is the current position.
{˜[m 1 ]∗ ˜[m 1 ]:∗ ˜[n 0 ]@∗}
⊲ Go-To. Jump m arguments forward, or backward, or
to argument n.
˜[limit][:][@]{text ˜}
⊲ Iteration. text is used repeatedly, up to limit, as con-
trol string for the elements of the list argument or (with
@) for the remaining arguments. With : or :@, list ele-
ments or remaining arguments should be lists of which
a new one is used at each iteration step.
ˆ ˆ ˜˜
˜ x ,y [,z ] ˆ
⊲ Escape Upward. Leave immediately ˜< ˜>,
Fu
˜< ˜:>, ˜{ ˜}, ˜?, or the entire format operation.
With one to three prefixes, act only if x = 0, x = y, or
x ≤ y ≤ z, respectively.

˜[i][:][@][[{text ˜;} text][˜:;default ]˜]

35
Common Lisp Quick Reference

⊲ Conditional Expression. The texts are format control


subclauses the zero-indexed argumenth (or the ith if
given) of which is chosen. With :, the argument is
boolean and takes first text for NIL and second text for
T. With @, the argument is boolean and if T, takes the
only text and remains to be read; no text is chosen and
the argument is used up if it is NIL.
˜[@]?
⊲ Recursive Processing. Process two arguments as
Fu
format string and argument list. With @, take one ar-
Fu
gument as format string and use then the rest oft the
original arguments.
ˆ ∗
˜
˜ prefix {, prefix } [:][@]/function/
⊲ Call Function. Call function with the arguments
stream, format-argument, colon-p, at-sign-p and
prefix es for printing format-argument.
˜[:][@]W
⊲ Write. Print argument of any type obeying every
printer control variable. With :, pretty-print. With
@, print without limits on length or depth.
{V #}
⊲ In place of the comma-separated prefix parameters:
use next argument or number of remaining unprocessed
arguments, respectively.

12.6 Streams
8˛ 8 9 9
>˛ >
>:input > > >
>
>˛ < = >
>
>
>˛ :output >
>
>˛:direction
> :input >
>
>
>˛ >
>:io >
> >
>

>˛ : ; >
>
>
> :probe >
>
>
>˛ >
>
>
>˛:element-type type character >
>
>
>˛ 8 >
>

>˛ >:new-version >
>
>
> >
> >
>
>
>˛ >
>:error >
>
>
>˛ >
> >
>
<˛ >:rename
> =
Fu ˛ <
(open path ˛ :rename-and-delete )
>
>˛ :if-exists >
>

> >:overwrite
> >
>
>
>˛ >
> >
>

>˛ >
>:append >
>
>
> >
> >
>
>
>˛ >
::supersede >
>
>
>˛ NIL >
>

> 8 >
>
>
>˛ >
>
>
>˛ <:error >
>
>
>˛ :if-does-not exist :create >
>

> >
>
>
>˛ : >
>

:˛ NIL >
;
:external-format format :default
⊲ Open file-stream to path .
Fu
(make-concatenated-stream input-stream ∗ )
Fu
(make-broadcast-stream output-stream ∗ )
Fu
(make-two-way-stream input-stream-part output-stream-part )
Fu
(make-echo-stream from-input-stream to-output-stream)
Fu
(make-synonym-stream variable-bound-to-stream)
⊲ Return stream of indicated type.
Fu ˆ ˜
(make-string-input-stream string start 0 [end NIL ] )
⊲ Return a string-stream supplying the characters from
string.
Fu
(make-string-output-stream [:element-type type character ])
⊲ Return a string-stream accepting characters (available via
Fu
get-output-stream-string).
Fu
(concatenated-stream-streams concatenated-stream )
Fu
(broadcast-stream-streams broadcast-stream )
⊲ Return list of streams concatenated-stream still has to
read from/broadcast-stream is broadcasting to.
Fu
(two-way-stream-input-stream two-way-stream)
Fu
(two-way-stream-output-stream two-way-stream)
Fu
(echo-stream-input-stream echo-stream)
Fu
(echo-stream-output-stream echo-stream)
⊲ Return source stream or sink stream of two-way-stream/
echo-stream, respectively.
Fu
(synonym-stream-symbol synonym-stream)
⊲ Return symbol of synonym-stream.

36
Common Lisp Quick Reference

Fu
^
(get-output-stream-string string-stream)
⊲ Clear and return as a string characters on string-stream.
Fu
(listen [stream ∗standard-input∗
var ])
⊲ T if there is a character in input stream.
Fu
^ ∗standard-input∗
(clear-input [stream var ])
⊲ Clear input from stream, return NIL.
8 Fu 9
<clear-output
Fu
=
^ ∗standard-output∗
( force-output [stream var ])
: Fu ;
finish-output
⊲ End output to stream and return NIL immediately, after
initiating flushing of buffers, or after flushing of buffers,
respectively.
Fu
^ [:abort bool NIL ])
(close stream
⊲ Close stream. Return T if stream had been open. If :abort
is T, delete associated file.
M
^ (declare decl
(with-open-stream (foo stream) d ∗ )∗ formP∗ )
⊲ Evaluate forms with foo locally bound to stream. Return
values of form s.
8˛ 9
<˛˛:index index
]=
M
(with-input-from-string (foo string ˛˛:start start 0 ) (declare
:˛ ;
:end end NIL
d ∗ )∗ formP∗ )
decl
⊲ Evaluate forms with foo locally bound to input
string-stream from string. Return values of form s; store
next reading position into index .
M
(with-output-to-string (foo [s^ tring NIL ] [:element-type type character ])
d ∗ )∗ formP∗ )
(declare decl
⊲ Evaluate forms with foo locally bound to an output
string-stream. Append output to string and return values
of form s if string is given. Return string containing output
otherwise.
Fu
(stream-external-format stream)
⊲ External file format designator.
var
∗terminal-io∗ ⊲ Bidirectional stream to user terminal.
var
∗standard-input∗
var
∗standard-output∗
var
∗error-output∗
⊲ Standard input stream, standard output stream, or stan-
dard error output stream, respectively.
var
∗debug-io∗
var
∗query-io∗
⊲ Bidirectional streams for debugging and user interaction.

12.7 Files
8˛ 9
> ˛:host host >
>
> ˛ >
>
> ˛ >
>˛:device dev
>
>
>
>
>
>
> ˛ :directory dir >
>
> ˛
<˛:name name >
=
Fu
(make-pathname ˛˛:type type )
>
> ˛ >
>
>
> ˛ >
>
>
>
> ˛:version ver >
>
>
> ˛ >
>˛:defaults path
>
:
>
>
˛:case {:local :common} :local ;
⊲ Construct pathname.
Fu
(merge-pathnames
ˆ pathname
default-pathname ∗default-pathname-defaults∗
var
˜
[default-version :newest ] )
⊲ Return pathname after filling in missing parts from de-
faults.
var
∗default-pathname-defaults∗
⊲ Pathname to use if one is needed and none supplied.
Fu
(pathname path) ⊲ Pathname of path.

37
Common Lisp Quick Reference

Fu
(enough-namestring path [root-path ∗default-pathname-defaults∗
var ])
⊲ Return minimal path string to sufficiently describe path
relative to root-path.
Fu
(namestring path)
Fu
(file-namestring path)
Fu
(directory-namestring path)
Fu
(host-namestring path)
⊲ Return string representing full pathname; name, type,
and version; directory name; or host name, respectively, of
path.
Fu ˆ
(parse-namestring foo host
ˆ
default-pathname ∗default-pathname-defaults∗
var
8˛ 9
˛
<˛:start start 0 =˜˜
˛:end end NIL )
:˛˛ ;
:junk-allowed bool NIL
⊲ Return pathname converted from string, pathname, or
stream foo; and position where parsing stopped.
2

8 Fu 9
> pathname-host >
>
> Fu >
>  ff
<pathname-device =
Fu :local
( pathname-directory path [:case ])
>
> Fu >
> :common :local
>pathname-name
: Fu
>
;
pathname-type
Fu
(pathname-version path)
⊲ Return pathname component.
Fu
(logical-pathname path) ⊲ Logical name of path.
Fu
(translate-pathname path-a path-b path-c)
⊲ Translate path-a from wildcard path-b into wildcard
path-c. Return new path.
Fu
(logical-pathname-translations host )
⊲ host ’s list of translations. setfable.
Fu
(load-logical-pathname-translations host )
⊲ Load host ’s translations. Return NIL if already loaded,
return T if successful.
Fu
(translate-logical-pathname path)
⊲ Physical pathname of path.
Fu
(probe-file file)
Fu
(truename file)
⊲ Canonical name of file. If file does not exist, return
NIL/signal file-error, respectively.
Fu
(file-write-date file) ⊲ Time at which file was last written.
Fu
(file-author file) ⊲ Return name of file owner.
Fu
(file-length stream) ⊲ Return length of stream .
8 9
Fu
<:start =
(file-position stream [ :end ])
: ;
position
⊲ Return position within stream, or set it to position and
return T on success.
Fu
(file-string-length stream foo)
⊲ Length foo would have in stream.
Fu
(rename-file foo bar )
⊲ Rename file foo to bar . Unspecified parts of path bar de-
fault to those of foo. Return new pathname, old file name,
2
and new file name.
3
Fu
(delete-file file) ⊲ Delete file, return T.
Fu
(directory path) ⊲ Return list of pathnames.
Fu
(ensure-directories-exist path [:verbose bool ])
⊲ Create parts of path if necessary. Second return value is
T if something has been created.
2

38
Common Lisp Quick Reference

M
d ∗ )∗ formP∗ )
(with-open-file (stream path open-arg ∗ ) (declare decl
Fu
⊲ Use open with open-arg s (cf. page 36) to temporarily
create stream to path; return values of form s.
Fu
(user-homedir-pathname [host ]) ⊲ User’s home directory.

13 Types and Classes


For any class, there is always a corresponding type of the same
name.
Fu
(typep foo type [environment NIL ])
⊲ Return T if foo is of type.
Fu
(subtypep type-a type-b [environment])
⊲ Return T if type-a is a recognizable subtype of type-b,
and NIL if the relationship could not be determined.
2

sO
d form)
(the type
⊲ Return values of form which are declared to be of type.
Fu
(coerce object type) ⊲ Coerce object into type.
 ff
ˆ ˜
M
d a-formP∗ )∗ ( otherwise b-form NILP∗ ) )
(typecase foo (type
T
⊲ Return values of the a-form s whose type is foo of. Return
values of b-form s if no type matches.
M ff
ctypecase d formP∗ )∗ )
( M foo (type
etypecase
⊲ Return values of the form s whose type is foo of. Sig-
nal correctable/non-correctable error, respectively if no type
matches.
Fu
(type-of foo) ⊲ Type of foo .

(check-type place type [string])


⊲ Return NIL and signal correctable type-error if place is
not of type.
Fu
(stream-element-type stream) ⊲ Return type of stream objects.
Fu
(array-element-type array ) ⊲ Element type array can hold.
Fu
(upgraded-array-element-type type [environment NIL ])
⊲ Element type of most specialized array capable of holding
elements of type.
M
d ∗ )∗ [doc]
(deftype foo (macro-λ∗ ) (declare decl d formP∗ )
⊲ Define type foo which when referenced as (foo argc ∗ ) ap-
plies expanded forms to args returning the new type. For
(macro-λ∗ ) see p. 18 but with default value of ∗ instead of
sO
NIL. form s are enclosed in an implicit block foo.

(eql foo)
⊲ Specifier for a type comprising foo or foos.
(member foo ∗ )

(satisfies predicate)
⊲ Type specifier for all objects satisfying predicate.

(mod n) ⊲ Type specifier for all non-negative integers < n.

(not type) ⊲ Complement of type.

(and type ∗ T ) ⊲ Type specifier for intersection of types.

(or type ∗ NIL ) ⊲ Type specifier for union of types.


ˆ ˜
(values type ∗ &optional type ∗ [&rest other-args ] )
⊲ Type specifier for multiple values.

39
Common Lisp Quick Reference

ˆ ˜
T number real lower-limit ∗ [upper-limit ∗ ]
ˆ ˜
rational lower-limit ∗ [upper-limit ∗ ]
ˆ ˜
integer lower-limit ∗ [upper-limit ∗ ]
signed-byte [size ∗ ]
unsigned-byte [size ∗ ] bit

fixnum; bignum
ratio
ˆ ˜
float lower-limit ∗ [upper-limit ∗ ]
ˆ ˜
short-float ˆlower-limit ∗ [upper-limit ∗ ] ˜
single-float ˆlower-limit ∗ [upper-limit ∗ ] ˜
ˆ lower-limit ∗ [upper-limit˜∗ ]
double-float
long-float lower-limit ∗ [upper-limit ∗ ]

complex [type ∗ ]
ˆ ˜
sequence list cons car-type ∗ [cdr-type ∗ ]
symbol† null
ˆ ˜
array† type ∗ [rank ∗ (dimension ∗ )]
ˆ ˜
simple-array† type ∗ [rank ∗ (dimension ∗ )]
ˆ ˜
vector† type ∗ [size ∗ ]
bit-vector† [size ∗ ]
simple-bit-vector [size ∗ ]
string† [size ∗ ]
simple-string [size ∗ ]
base-string† [size ∗ ]
simple-base-string [size ∗ ]

simple-vector [size ∗ ]
ˆ ˜
vector type ∗ [size ∗ ]
string[size ∗ ] base-string[size ∗ ]
bit-vector[size ∗ ]
ˆ ˜
array type ∗ [rank ∗ (dimension ∗ )]
ˆ ˜
simple-array type ∗ [rank ∗ (dimension ∗ )]

character base-char standard-char


extended-char

stream file-stream; two-way-stream; synonym-stream;


string-stream; broadcast-stream; echo-stream;
concatenated-stream

pathname logical-pathname

symbol keyword; boolean


ˆ ˜
function arg-types [value-types]
generic-function standard-generic-function
compiled-function

standard-object class standard-class; built-in-class;


structure-class

method† standard-method

atom; hash-table; structure-object; package; readtable;


random-state; restart; method; method-combination

For supertypes of this type look for the instance without a † .
As a type argument, ∗ means no restriction.

Figure 3: Data Types.

40
Common Lisp Quick Reference

14 Packages and Symbols


14.1 Predicates
Fu
(symbolp foo)
Fu
(packagep foo) ⊲ T if foo is of indicated type.
Fu
(keywordp foo)

14.2 Packages
:bar keyword:bar ⊲ Keyword, evaluates to :bar .

package:symbol ⊲ Exported symbol of package.

package::symbol ⊲ Possibly unexported symbol of package.


8˛ 9
> ˛(:nicknames nick ∗ )∗ >

> >
>
>
> ˛(:documentation string) >
>
> ˛
>˛(:intern interned-symbol ∗ )∗ >
>
>
> >
>
>
> ˛ ∗ ∗ >
>
<˛(:use used-package ) =
M ˛ ∗ ∗
(defpackage foo ˛(:import-from pkg imported-symbol ) )
>
> ˛ >
>
> ˛(:shadowing-import-from pkg shd-symbol ∗ )∗ >
>
>
>
> ˛ >
>
>
> ˛(:shadow shd-symbol ∗ )∗ >
>
>˛˛(:export exported-symbol ∗ )∗
> >
>
>
:˛ >
;
(:size int)
⊲ Create or modify package foo with interned-symbol s,
symbols from used-package s, imported-symbol s, and
shd-symbol s. Add shd-symbol s to foo’s shadowing list.
˛ ff
Fu ˛:nicknames (nick ∗ ) NIL
(make-package foo ˛˛ ∗ )
:use (used-package )
⊲ Create package foo.
Fu
(rename-package package new-name [new-nicknames NIL ])
⊲ Rename package. Return renamed package.
M
c
(in-package foo) ⊲ Make package foo current.
 Fu ff
use-package
( Fu other-packages [package ∗package∗
var ])
unuse-package
⊲ Make exported symbols of other-packages available in
package, or remove them from package, respectively. Re-
turn T.
Fu
(package-use-list package)
Fu
(package-used-by-list package)
⊲ List of other packages used by/using package.

Fu
^
(delete-package package)
⊲ Delete package. Return T if successful.
var
∗package∗ common-lisp-user ⊲ The current package.
Fu
(list-all-packages) ⊲ List of registered packages.
Fu
(package-name package) ⊲ Name of package .
Fu
(package-nicknames package) ⊲ List of nicknames of package.
Fu
(find-package name)
⊲ Package object with name (case-sensitive).
Fu
(find-all-symbols name)
⊲ Return list of symbols with name from all registered
packages.
 Fu ff
intern
( Fu foo [package ∗package∗
var ])
find-symbol
⊲ Intern or find, respectively, symbol foo in package. Sec-
ond return value is one of :internal, :external, or :inherited
Fu 2 2 2
(or NIL if intern created a fresh symbol).
2
Fu
(unintern symbol [package ∗package∗
var ])
⊲ Remove symbol from package, return T on success.

41
Common Lisp Quick Reference
 Fu ff
import
( Fu symbols [package ∗package∗
var ])
shadowing-import
⊲ Make symbols internal to package. Return T. In case of
a name conflict signal correctable package-error or shadow
the old symbol, respectively.
Fu
(shadow symbols [package ∗package∗
var ])
⊲ Add symbols to shadowing list of package making equally
named inherited symbols shadowed. Return T.
Fu
(package-shadowing-symbols package)
⊲ List of shadowing symbols of package.
Fu
(export symbols [package ∗package∗
var ])
⊲ Make symbols external to package. Return T.
Fu
(unexport symbols [package ∗package∗
var ])
⊲ Revert symbols to internal status. Return T.
8M ff 9
<do-symbols ˆ ˜=
M (d
var package ∗package∗
var [result NIL ] )
( do-external-symbols
:M ;
do-all-symbols (var [result NIL ])
˛ ff
˛ c
d ∗ )∗ ˛tag
(declare decl ∗
˛form )
sO
⊲ Evaluate tagbody-like body with var successively bound
to every symbol from package, to every external symbol
from package, or to every symbol from all registered pack-
ages, respectively. Return values of result . Implicitly, the
sO
whole form is a block named NIL.
M
(with-package-iterator (foo packages [:internal :external :inherited])
d ∗ )∗ formP∗ )
(declare decl
⊲ Return values of form s. In forms, successive invocations
of (foo) return: T if a symbol is returned; a symbol from
packages; accessibility (:internal, :external, or :inherited);
and the package the symbol belongs to.
Fu
(require module [path-list NIL ])
var
⊲ If not in ∗modules∗, try paths in path-list to load module
from. Signal error if unsuccessful. Deprecated.
Fu
(provide module )
var
⊲ If not already there, add module to ∗modules∗. Depre-
cated.
var
∗modules∗ ⊲ List of names of loaded modules.

14.3 Symbols
A symbol has the attributes name, home package, property list, and
optionally value (of global constant or variable name) and function
(function, macro, or special operator name).
Fu
(make-symbol name)
⊲ Make fresh, uninterned symbol name.
Fu
(gensym [s G ])
⊲ Return fresh, uninterned symbol #:sn with n from
var var
∗gensym-counter∗. Increment ∗gensym-counter∗.
Fu ˆ ˜
(gentemp prefix T [package ∗package∗
var ] )
⊲ Intern fresh symbol in package. Deprecated.
Fu
(copy-symbol symbol [props NIL ])
⊲ Return uninterned copy of symbol . If props is T, give
copy the same value, function and property list.
Fu
(symbol-name symbol )
Fu
(symbol-package symbol )
Fu
(symbol-plist symbol )
Fu
(symbol-value symbol )
Fu
(symbol-function symbol )
⊲ Name, package, property list, value, or function, respec-
tively, of symbol . setfable.
 gF ff
documentation
( gF foo {’variable ’function
(setf documentation) new-doc
’compiler-macro ’method-combination ’structure ’type ’setf
T})
⊲ Get/set documentation string of foo of given type.

42
Common Lisp Quick Reference

co
t
⊲ Truth; the supertype of every type including t; the su-
var
perclass of every class except t; ∗terminal-io∗.
co co
nil ()
⊲ Falsity; the empty list; the empty type, subtype of ev-
var var
ery type; ∗standard-input∗; ∗standard-output∗; the global
environment.

14.4 Standard Packages


common-lisp cl
⊲ Exports the defined names of Common Lisp except for
those in the keyword package.

common-lisp-user cl-user
⊲ Current package after startup; uses package common-lisp.

keyword
⊲ Contains symbols which are defined to be of type
keyword.

15 Compiler
15.1 Predicates
Fu
(special-operator-p foo) ⊲ T if foo is a special operator.
Fu
(compiled-function-p foo)
⊲ T if foo is of type compiled-function.

15.2 Compilation
8 9
<NIL
 definitionff =
Fu
(compile name )
: [definition];
(setf name)
⊲ Return compiled function or replace name’s function def-
inition with the compiled function. Return T in case of
2
warnings or errors, and T in case of warnings or errors ex-
3
cluding style warnings.
8˛ 9
> ˛:output-file out-path >
>
<˛˛:verbose bool var >
=
Fu
(compile-file file ˛˛ ∗compile-verbose∗
)
>
> :print bool var >
:˛˛ ∗compile-print∗ >
;
:external-format file-format :default
⊲ Write compiled contents of file to out-path. Return true
output path or NIL, T in case of warnings or errors, T in case
2 3
of warnings or errors excluding style warnings.
Fu
(compile-file-pathname file [:output-file path] [other-keyargs])
Fu
⊲ Pathname compile-file writes to if invoked with the same
arguments.
8˛ 9
> ˛:verbose bool var >
<˛˛:print bool var∗load-verbose∗
> >
=
Fu
(load path ˛ ˛ ∗load-print∗
)
>
> :if-does-not-exist bool >
:˛˛ T >
;
:external-format file-format :default
⊲ Load source file or compiled file into Lisp environment.
Return T if successful.
var ff
∗compile-file pathname∗ NIL
var -
∗load truename∗ NIL
Fu Fu
⊲ Input file used by compile-file/by load.
var ff
∗compile print∗
var -
∗load verbose∗
Fu Fu
⊲ Defaults used by compile-file/by load.
8˛ 9
<˛˛{:compile-toplevel compile}=
sO P
(eval-when ( ˛˛{:load-toplevel load} ) form ∗ )
:˛ ;
{:execute eval}
sO
⊲ Return values of form s if eval-when is in the top-level of a
file being compiled, in the top-level of a compiled file being
loaded, or anywhere, respectively. Return NIL if forms are
not evaluated. (compile, load and eval deprecated.)

43
Common Lisp Quick Reference

sO
d ∗ )∗ form ∗ )
(locally (declare decl
P

⊲ Evaluate forms in a lexical environment with declarations


decl in effect. Return values of form s.
M P
(with-compilation-unit ([:override bool NIL ]) form ∗ )
⊲ Return values of form s. Warnings deferred by the com-
piler until end of compilation are deferred until the end of
evaluation of forms.
sO
\ NIL ])
(load-time-value form [read-only
⊲ Evaluate form at compile time and treat its value as lit-
eral at run time.
sO
c
(quote foo) ⊲ Return unevaluated foo.
gF
(make-load-form foo [environment ])
⊲ Its methods are to return a creation form which on eval-
Fu
uation at load time returns an object equivalent to foo, and
an optional initialization form which on evaluation performs
2
some initialization of the object.
˛ ff
Fu ˛:slot-names slots all local slots
(make-load-form-saving-slots foo ˛˛ )
:environment environment
⊲ Return a creation form and an initialization form which
2
on evaluation construct an object equivalent to foo with
slots initialized with the corresponding values from foo.
Fu
(macro-function symbol [environment])
 ff
Fu name
(compiler-macro-function [environment])
(setf name)
⊲ Return specified macro function, or compiler macro func-
tion, respectively, if any. Return NIL otherwise. setfable.
Fu
(eval arg)
⊲ Return values of value of arg evaluated in global environ-
ment.

15.3 REPL and Debugging


var var var
+ ++ +++
var var var
∗ ∗∗ ∗∗∗
var var var
/ // ///
⊲ Last, penultimate, or antepenultimate form evaluated
in the REPL, or their respective primary value, or a list of
their respective values.
var
– ⊲ Form currently being evaluated by the REPL.
Fu
(apropos string [package NIL ])
⊲ Print interned symbols containing string.
Fu
(apropos-list string [package NIL ])
⊲ List of interned symbols containing string.
Fu
(dribble [path])
⊲ Save a record of interactive session to file at path. With-
out path, close that file.
Fu
(ed [file-or-function NIL ]) ⊲ Invoke editor if possible.
 Fu ff
macroexpand-1
( Fu form [environment NIL ])
macroexpand
⊲ Return macro expansion, once or entirely, respectively,
of form and T if form was a macro form. Return form and
2
NIL otherwise.
2
var
∗macroexpand-hook∗
⊲ Function of arguments expansion function, macro form,
Fu
and environment called by macroexpand-1 to generate
macro expansions.
 ff∗
M function
(trace )
(setf function)
⊲ Cause functions to be traced. With no arguments, return
list of traced functions.

44
Common Lisp Quick Reference
 ff∗
M function
(untrace )
(setf function)
⊲ Stop functions, or each currently traced function, from
being traced.
var
∗trace-output∗
M M
⊲ Stream trace and time print their output on.

M
(step form )
⊲ Step through evaluation of form. Return values of form .

Fu
(break [control arg ∗ ])
⊲ Jump directly into debugger; return NIL. See p. 34,
Fu
format, for control and arg s.
M
(time form)
⊲ Evaluate forms and print timing information to
var
∗trace-output∗. Return values of form .
Fu
(inspect foo) ⊲ Interactively give information about foo.

Fu
^ ∗standard-output∗
(describe foo [stream var ])
⊲ Send information about foo to stream.

gF
^
(describe-object foo [stream])
⊲ Send information about foo to stream. Not to be called
by user.
Fu
(disassemble function)
⊲ Send disassembled representation of function to
var
∗standard-output∗. Return NIL.

15.4 Declarations
Fu
(proclaim decl )
M
d ∗)
(declaim decl
⊲ Globally make declaration(s) decl . decl can be:
declaration, type, ftype, inline, notinline, optimize, or
special. See below.

d ∗)
(declare decl
⊲ Inside certain forms, locally make declarations decl ∗ .
decl can be: dynamic-extent, type, ftype, ignorable, ignore,
inline, notinline, optimize, or special. See below.

(declaration foo∗ )
⊲ Make foos names of declarations.
sO
(dynamic-extent variable ∗ (function function)∗ )
⊲ Declare lifetime of variables and/or functions to end
when control leaves enclosing block.
([type] type variable ∗ )
(ftype type function ∗ )
⊲ Declare variables or functions to be of type.
 ff ff∗
ignorable var
( sO )
ignore (function function)
⊲ Suppress warnings about used/unused bindings.
(inline function ∗ )
(notinline function ∗ )
⊲ Tell compiler to integrate/not to integrate, respec-
tively, called functions into the calling routine.
8˛ 9
> ˛compilation-speed (compilation-speed n 3 )>

> >
>
>
<˛˛debug (debug n 3 ) >
=
˛
(optimize ˛safety (safety n 3 ) )
>
> ˛ >
>
>
>˛space (space n 3 ) >
>
: ˛speed (speed n ) ;
3
⊲ Tell compiler how to optimize. n = 0 means unim-
portant, n = 1 is neutral, n = 3 means important.
(special var ∗ ) ⊲ Declare var s to be dynamic.

45
Common Lisp Quick Reference

16 External Environment
Fu
(get-internal-real-time)
Fu
(get-internal-run-time)
⊲ Current time, or computing time, respectively, in clock
ticks.
co
internal-time-units-per-second
⊲ Number of clock ticks per second.
Fu
(encode-universal-time sec min hour date month year [zone curr ])
Fu
(get-universal-time)
⊲ Seconds from 1900-01-01, 00:00.
Fu
(decode-universal-time universal-time [time-zone current ])
Fu
(get-decoded-time)
⊲ Return second, minute, hour, date, month, year, day,
2 3 4 5 6 7
daylight-p, and zone.
8 9
Fu
(room [{NIL :default T}])
⊲ Print information about internal storage management.
Fu
(short-site-name)
Fu
(long-site-name)
⊲ String representing physical location of computer.
8 Fu 9
<lisp-implementation = ff
Fu type
( software - )
: Fu ; version
machine
⊲ Name or version of implementation, operating system, or
hardware, respectively.
Fu
(machine-instance) ⊲ Computer name.

46
Common Lisp Quick Reference

Index
” 31 &AUX 19 BIT-ANDC1 11 COMPILED-
’ 31 &BODY 19 BIT-ANDC2 11 FUNCTION-P 43
( 31 &ENVIRONMENT 19 BIT-EQV 11 COMPILER-MACRO 42
() 43 &KEY 19 BIT-IOR 11 COMPILER-MACRO-
∗ 40 &OPTIONAL 19 BIT-NAND 11 FUNCTION 44
∗ 3, 44 &REST 19 BIT-NOR 11 COMPLEMENT 17
∗∗ 44 &WHOLE 19 BIT-NOT 11 COMPLEX 4, 40
∗∗∗ 44 ∼( ∼) 35 BIT-ORC1 11 COMPLEXP 3
∗BREAK- ∼∗ 35 BIT-ORC2 11 COMPUTE-
ON-SIGNALS∗ 29 ∼/ / 36 BIT-VECTOR 40 APPLICABLE-
∗COMPILE-FILE- ∼< ∼:> 35 BIT-VECTOR-P 10 METHODS 25
PATHNAME∗ 43 ∼< ∼> 35 BIT-XOR 11 COMPUTE-RESTARTS
∗COMPILE-FILE- ∼? 36 BLOCK 20 28
TRUENAME∗ 43 ∼A 34 BOOLE 4 CONCATENATE 12
∗COMPILE-PRINT∗ 43 ∼B 34 BOOLE-1 4 CONCATENATED-
∗COMPILE- ∼C 35 BOOLE-2 4 STREAM 40
VERBOSE∗ 43 ∼D 34 BOOLE-AND 5 CONCATENATED-
∗DEBUG-IO∗ 37 ∼E 34 BOOLE-ANDC1 5 STREAM-STREAMS
∗DEBUGGER-HOOK∗ ∼F 34 BOOLE-ANDC2 5 36
29 ∼G 34 BOOLE-C1 4 COND 19
∗DEFAULT- ∼I 35 BOOLE-C2 4 CONDITION 29
PATHNAME- ∼O 34 BOOLE-CLR 4 CONJUGATE 4
DEFAULTS∗ 37 ∼P 35 BOOLE-EQV 5 CONS 8, 40
∗ERROR-OUTPUT∗ 37 ∼R 34 BOOLE-IOR 5 CONSP 8
∗FEATURES∗ 32 ∼S 34 BOOLE-NAND 5 CONSTANTLY 17
∗GENSYM- ∼T 35 BOOLE-NOR 5 CONSTANTP 15
COUNTER∗ 42 ∼W 36 BOOLE-ORC1 5 CONTINUE 28
∗LOAD-PATHNAME∗ ∼X 34 BOOLE-ORC2 5 CONTROL-ERROR 29
43 ∼[ ∼] 36 BOOLE-SET 4 COPY-ALIST 9
∗LOAD-PRINT∗ 43 ∼$ 35 BOOLE-XOR 5 COPY-LIST 9
∗LOAD-TRUENAME∗ ∼% 35 BOOLEAN 40 COPY-PPRINT-
43 ∼& 35 BOTH-CASE-P 6 DISPATCH 34
∗LOAD-VERBOSE∗ 43 ∼ˆ 35 BOUNDP 15 COPY-READTABLE 30
∗MACROEXPAND- ∼ 35 BREAK 45 COPY-SEQ 14
HOOK∗ 44 ∼| 35 BROADCAST- COPY-STRUCTURE 15
∗MODULES∗ 42 ∼{ ∼} 35 STREAM 40 COPY-SYMBOL 42
∗PACKAGE∗ 41 ∼∼ 35 BROADCAST- COPY-TREE 10
∗PRINT-ARRAY∗ 33 ` 31 STREAM-STREAMS COS 3
∗PRINT-BASE∗ 33 | | 32 36 COSH 3
∗PRINT-CASE∗ 33 1+ 3 BUILT-IN-CLASS 40 COUNT 12, 23
∗PRINT-CIRCLE∗ 33 1– 3 BUTLAST 9 COUNT-IF 12
∗PRINT-ESCAPE∗ 33 BY 21 COUNT-IF-NOT 12
∗PRINT-GENSYM∗ 33 BYTE 5 COUNTING 23
ABORT 28
∗PRINT-LENGTH∗ 33 BYTE-POSITION 5 CTYPECASE 39
ABOVE 21
∗PRINT-LEVEL∗ 33 BYTE-SIZE 5
ABS 4
∗PRINT-LINES∗ 33
ACONS 9
∗PRINT- DEBUG 45
ACOS 3 DECF 3
MISER-WIDTH∗ 33
ACOSH 4 CAAR 9
∗PRINT-PPRINT- DECLAIM 45
ACROSS 21 CADR 9 DECLARATION 45
DISPATCH∗ 34
ADD-METHOD 25 CALL-ARGUMENTS-
∗PRINT-PRETTY∗ 34 DECLARE 45
ADJOIN 9 LIMIT 17
∗PRINT-RADIX∗ 34 DECODE-FLOAT 6
ADJUST-ARRAY 10 CALL-METHOD 26
∗PRINT-READABLY∗ DECODE-UNIVERSAL-
ADJUSTABLE- CALL-NEXT-METHOD
34 TIME 46
ARRAY-P 10 25
∗PRINT-RIGHT- DEFCLASS 23
ALLOCATE-INSTANCE CAR 8
MARGIN∗ 34 DEFCONSTANT 16
24 CASE 19
∗QUERY-IO∗ 37 DEFGENERIC 24
ALPHA-CHAR-P 6 CATCH 20
∗RANDOM-STATE∗ 4 DEFINE-COMPILER-
ALPHANUMERICP 6 CCASE 19
∗READ-BASE∗ 30 MACRO 18
ALWAYS 23 CDAR 9
∗READ-DEFAULT- DEFINE-CONDITION
AND 19, 21, 26, 39 CDDR 9
FLOAT-FORMAT∗ 27
APPEND 9, 23, 26 CDR 8
30 DEFINE-METHOD-
APPENDING 23 CEILING 4
∗READ-EVAL∗ 31 COMBINATION 26
APPLY 17 CELL-ERROR 29
∗READ-SUPPRESS∗ 31 DEFINE-MODIFY-
APROPOS 44 CELL-ERROR-NAME
∗READTABLE∗ 30 MACRO 19
APROPOS-LIST 44 28
∗STANDARD-INPUT∗ DEFINE-SETF-
AREF 10 CERROR 27
37 EXPANDER 18
ARITHMETIC-ERROR CHANGE-CLASS 24
∗STANDARD- DEFINE-SYMBOL-
29 CHAR 8
OUTPUT∗ 37 MACRO 18
ARITHMETIC-ERROR- CHAR-CODE 7
∗TERMINAL-IO∗ 37 DEFMACRO 18
OPERANDS 28 CHAR-CODE-LIMIT 7
∗TRACE-OUTPUT∗ 45 DEFMETHOD 25
ARITHMETIC-ERROR- CHAR-DOWNCASE 7
+ 3, 26, 44 DEFPACKAGE 41
OPERATION 28 CHAR-EQUAL 6
++ 44 DEFPARAMETER 16
ARRAY 40 CHAR-GREATERP 7
+++ 44 DEFSETF 18
ARRAY-DIMENSION 11 CHAR-INT 7
, 31 DEFSTRUCT 15
ARRAY-DIMENSION- CHAR-LESSP 7
,. 31 DEFTYPE 39
LIMIT 11 CHAR-NAME 7
,@ 31 DEFUN 16
ARRAY-DIMENSIONS CHAR-NOT-EQUAL 6
– 3, 44 DEFVAR 16
11 CHAR-
/ 3, 44 DELETE 13
ARRAY- NOT-GREATERP 7
// 44 DELETE-DUPLICATES
DISPLACEMENT 11 CHAR-NOT-LESSP 7
/// 44 13
ARRAY- CHAR-UPCASE 7
/= 3 DELETE-FILE 38
ELEMENT-TYPE 39 CHAR/= 6
: 41 DELETE-IF 13
ARRAY-HAS- CHAR< 6
:: 41 DELETE-IF-NOT 13
FILL-POINTER-P 10 CHAR<= 6
:ALLOW- DELETE-PACKAGE 41
ARRAY-IN-BOUNDS-P CHAR= 6
OTHER-KEYS 19 DENOMINATOR 4
10 CHAR> 6
; 31 DEPOSIT-FIELD 5
ARRAY-RANK 11 CHAR>= 6
< 3 DESCRIBE 45
ARRAY-RANK-LIMIT CHARACTER 7, 40
<= 3 DESCRIBE-OBJECT 45
11 CHARACTERP 6
= 3, 21 DESTRUCTURING-
ARRAY-ROW- CHECK-TYPE 39
> 3 BIND 20
MAJOR-INDEX 11
>= 3 CIS 4 DIGIT-CHAR 7
ARRAY-TOTAL-SIZE
\ 32 CL 43 DIGIT-CHAR-P 6
11
# 36 CL-USER 43 DIRECTORY 38
ARRAY-TOTAL-
#\ 31 CLASS 40 DIRECTORY-
SIZE-LIMIT 11
#’ 31 CLASS-NAME 24 NAMESTRING 38
ARRAYP 10
#( 31 CLASS-OF 24 DISASSEMBLE 45
AS 21
#∗ 31 CLEAR-INPUT 37 DIVISION-BY-ZERO 29
ASH 5
#+ 32 CLEAR-OUTPUT 37 DO 20, 21
ASIN 3
#– 32 CLOSE 37 DO-ALL-SYMBOLS 42
ASINH 4
#. 31 CLRHASH 14 DO-EXTERNAL-
ASSERT 27
#: 31 CODE-CHAR 7 SYMBOLS 42
ASSOC 9
#< 31 COERCE 39 DO-SYMBOLS 42
ASSOC-IF 9
#= 31 COLLECT 23 DO∗ 20
ASSOC-IF-NOT 9
#A 31 COLLECTING 23 DOCUMENTATION 42
ATAN 3
#B 31 COMMON-LISP 43 DOING 21
ATANH 4
#C( 31 COMMON-LISP-USER DOLIST 21
ATOM 8, 40
#O 31 43 DOTIMES 20
#P 31 COMPILATION-SPEED DOUBLE-FLOAT 40
#R 31 BASE-CHAR 40 45 DOUBLE-
#S( 31 BASE-STRING 40 COMPILE 43 FLOAT-EPSILON 6
#X 31 BEING 21 COMPILE-FILE 43 DOUBLE-FLOAT-
## 31 BELOW 21 COMPILE-FILE- NEGATIVE-EPSILON
#| |# 31 BIGNUM 40 PATHNAME 43 6
&ALLOW- BIT 11, 40 COMPILED- DOWNFROM 21
OTHER-KEYS 19 BIT-AND 11 FUNCTION 40 DOWNTO 21

47
Common Lisp Quick Reference

DPB 5 GENSYM 42 LEAST-NEGATIVE- MAKE-SYNONYM-


DRIBBLE 44 GENTEMP 42 SHORT-FLOAT 6 STREAM 36
DYNAMIC-EXTENT 45 GET 16 LEAST-NEGATIVE- MAKE-TWO-
GET-DECODED-TIME SINGLE-FLOAT 6 WAY-STREAM 36
46 LEAST-POSITIVE- MAKUNBOUND 16
EACH 21
GET- DOUBLE-FLOAT 6 MAP 14
ECASE 19
DISPATCH-MACRO- LEAST-POSITIVE- MAP-INTO 14
ECHO-STREAM 40
CHARACTER 31 LONG-FLOAT 6 MAPC 9
ECHO-STREAM-
GET-INTERNAL- LEAST-POSITIVE- MAPCAN 9
INPUT-STREAM 36
REAL-TIME 46 NORMALIZED- MAPCAR 9
ECHO-STREAM-
GET-INTERNAL- DOUBLE-FLOAT 6 MAPCON 9
OUTPUT-STREAM
RUN-TIME 46 LEAST-POSITIVE- MAPHASH 14
36
GET-MACRO- NORMALIZED- MAPL 9
ED 44
CHARACTER 31 LONG-FLOAT 6 MAPLIST 9
EIGHTH 8
GET-OUTPUT- LEAST-POSITIVE- MASK-FIELD 5
ELSE 21
STREAM-STRING 37 NORMALIZED- MAX 4, 26
ELT 12
GET-PROPERTIES 16 SHORT-FLOAT 6 MAXIMIZE 23
ENCODE-UNIVERSAL-
GET-SETF- LEAST-POSITIVE- MAXIMIZING 23
TIME 46
EXPANSION 19 NORMALIZED- MEMBER 8, 39
END 21
GET-UNIVERSAL- SINGLE-FLOAT 6 MEMBER-IF 8
END-OF-FILE 29
TIME 46 LEAST-POSITIVE- MEMBER-IF-NOT 8
ENDP 8
GETF 16 SHORT-FLOAT 6 MERGE 12
ENOUGH-
GETHASH 14 LEAST-POSITIVE- MERGE-PATHNAMES
NAMESTRING 38
GO 20 SINGLE-FLOAT 6 37
ENSURE-
GRAPHIC-CHAR-P 6 LENGTH 12 METHOD 40
DIRECTORIES-
LET 20 METHOD-
EXIST 38
LET∗ 20 COMBINATION
ENSURE-GENERIC- HANDLER-BIND 27 LISP- 40, 42
FUNCTION 25 HANDLER-CASE 27 IMPLEMENTATION- METHOD-
EQ 15 HASH-KEY 21 TYPE 46 COMBINATION-
EQL 15, 39 HASH-KEYS 21 LISP- ERROR 25
EQUAL 15 HASH-TABLE 40 IMPLEMENTATION- METHOD-
EQUALP 15 HASH-TABLE-COUNT VERSION 46 QUALIFIERS 26
ERROR 27, 29 14 LIST 8, 26, 40 MIN 4, 26
ETYPECASE 39 HASH-TABLE-P 14 LIST-ALL-PACKAGES MINIMIZE 23
EVAL 44 HASH-TABLE- 41 MINIMIZING 23
EVAL-WHEN 43 REHASH-SIZE 14 LIST-LENGTH 8 MINUSP 3
EVENP 3 HASH- LIST∗ 8 MISMATCH 12
EVERY 12 TABLE-REHASH-
EXP 3 LISTEN 37 MOD 4, 39
THRESHOLD 14 LISTP 8 MOST-NEGATIVE-
EXPORT 42 HASH-TABLE-SIZE 14
EXPT 3 LOAD 43 DOUBLE-FLOAT 6
HASH-TABLE-TEST 14 LOAD-LOGICAL- MOST-NEGATIVE-
EXTENDED-CHAR 40 HASH-VALUE 21
EXTERNAL-SYMBOL PATHNAME- FIXNUM 6
HASH-VALUES 21 TRANSLATIONS 38 MOST-NEGATIVE-
21 HOST-NAMESTRING
EXTERNAL-SYMBOLS LOAD-TIME-VALUE 44 LONG-FLOAT 6
38 LOCALLY 44 MOST-NEGATIVE-
21
LOG 3 SHORT-FLOAT 6
LOGAND 5 MOST-NEGATIVE-
FBOUNDP 15 IDENTITY 17 LOGANDC1 5 SINGLE-FLOAT 6
FCEILING 4 IF 19, 21 LOGANDC2 5 MOST-POSITIVE-
FDEFINITION 17 IGNORABLE 45 LOGBITP 5 DOUBLE-FLOAT 6
FFLOOR 4 IGNORE 45 LOGCOUNT 5 MOST-POSITIVE-
FIFTH 8 IGNORE-ERRORS 27 LOGEQV 5 FIXNUM 6
FILE-AUTHOR 38 IMAGPART 4 LOGICAL-PATHNAME MOST-POSITIVE-
FILE-ERROR 29 IMPORT 42 38, 40 LONG-FLOAT 6
FILE-ERROR- IN 21 LOGICAL-PATHNAME- MOST-POSITIVE-
PATHNAME 28 IN-PACKAGE 41 TRANSLATIONS 38 SHORT-FLOAT 6
FILE-LENGTH 38 INCF 3 LOGIOR 5 MOST-POSITIVE-
FILE-NAMESTRING 38 INITIALIZE-INSTANCE
LOGNAND 5 SINGLE-FLOAT 6
FILE-POSITION 38 24
LOGNOR 5 MUFFLE-WARNING 28
FILE-STREAM 40 INITIALLY 23
LOGNOT 5 MULTIPLE-
FILE-STRING-LENGTH INLINE 45
LOGORC1 5 VALUE-BIND 20
38 INPUT-STREAM-P 29
LOGORC2 5 MULTIPLE-
FILE-WRITE-DATE 38 INSPECT 45
LOGTEST 5 VALUE-CALL 17
FILL 12 INTEGER 40
LOGXOR 5 MULTIPLE-
FILL-POINTER 11 INTEGER-
LONG-FLOAT 40 VALUE-LIST 17
FINALLY 23 DECODE-FLOAT 6
LONG- MULTIPLE-
FIND 13 INTEGER-LENGTH 5
FLOAT-EPSILON 6 VALUE-PROG1 19
FIND-ALL-SYMBOLS INTEGERP 3
LONG-FLOAT- MULTIPLE-
41 INTERACTIVE-
NEGATIVE-EPSILON VALUE-SETQ 16
FIND-CLASS 24 STREAM-P 29
6 MULTIPLE-
FIND-IF 13 INTERN 41
LONG-SITE-NAME 46 VALUES-LIMIT 17
FIND-IF-NOT 13 INTERNAL-
LOOP 21
FIND-METHOD 25 TIME-UNITS-
LOOP-FINISH 23
FIND-PACKAGE 41 PER-SECOND 46
LOWER-CASE-P 6 NAME-CHAR 7
FIND-RESTART 28 INTERSECTION 10
NAMED 21
FIND-SYMBOL 41 INTO 23
NAMESTRING 38
FINISH-OUTPUT 37 INVALID-METHOD-
MACHINE-INSTANCE NBUTLAST 9
FIRST 8 ERROR 25
46 NCONC 9, 23, 26
FIXNUM 40 INVOKE-DEBUGGER
MACHINE-TYPE 46 NCONCING 23
FLET 17 27
MACHINE-VERSION 46 NEVER 23
FLOAT 4, 40 INVOKE-RESTART 28
MACRO-FUNCTION 44 NEXT-METHOD-P 24
FLOAT-DIGITS 6 INVOKE-RESTART-
MACROEXPAND 44 NIL 2, 43
FLOAT-PRECISION 6 INTERACTIVELY 28
MACROEXPAND-1 44 NINTERSECTION 10
FLOAT-RADIX 6 ISQRT 3
MACROLET 18 NINTH 8
FLOAT-SIGN 4 IT 21, 23
MAKE-ARRAY 10 NO-APPLICABLE-
FLOATING- METHOD 25
MAKE-BROADCAST-
POINT-INEXACT 29 STREAM 36 NO-NEXT-METHOD
FLOATING- KEYWORD 40, 41, 43
KEYWORDP 41 MAKE- 25
POINT-INVALID- NOT 15, 39
CONCATENATED-
OPERATION 29 NOTANY 12
STREAM 36
FLOATING-POINT- NOTEVERY 12
LABELS 17 MAKE-CONDITION 27
OVERFLOW 29 NOTINLINE 45
LAMBDA 16 MAKE-
FLOATING-POINT-
LAMBDA-LIST- DISPATCH-MACRO- NRECONC 9
UNDERFLOW 29
KEYWORDS 19 CHARACTER 31 NREVERSE 12
FLOATP 3
LAMBDA- MAKE- NSET-DIFFERENCE 10
FLOOR 4
PARAMETERS- ECHO-STREAM 36 NSET-EXCLUSIVE-OR
FMAKUNBOUND 17
LIMIT 17 MAKE-HASH-TABLE 10
FOR 21
LAST 9 14 NSTRING-CAPITALIZE
FORCE-OUTPUT 37
LCM 3 MAKE-INSTANCE 24 7
FORMAT 34
LDB 5 MAKE-INSTANCES- NSTRING-DOWNCASE
FORMATTER 34
LDB-TEST 5 OBSOLETE 24 7
FOURTH 8
LDIFF 9 MAKE-LIST 8 NSTRING-UPCASE 7
FRESH-LINE 32
LEAST-NEGATIVE- MAKE-LOAD-FORM 44 NSUBLIS 10
FROM 21
DOUBLE-FLOAT 6 MAKE-LOAD-FORM- NSUBST 10
FROUND 4
LEAST-NEGATIVE- SAVING-SLOTS 44 NSUBST-IF 10
FTRUNCATE 4
LONG-FLOAT 6 MAKE-METHOD 26 NSUBST-IF-NOT 10
FTYPE 45
LEAST-NEGATIVE- MAKE-PACKAGE 41 NSUBSTITUTE 13
FUNCALL 17
NORMALIZED- MAKE-PATHNAME 37 NSUBSTITUTE-IF 13
FUNCTION 17, 40, 42
DOUBLE-FLOAT 6 MAKE- NSUBSTITUTE-
FUNCTION-
LEAST-NEGATIVE- RANDOM-STATE 4 IF-NOT 13
KEYWORDS 26
NORMALIZED- MAKE-SEQUENCE 12 NTH 8
FUNCTION-LAMBDA-
LONG-FLOAT 6 MAKE-STRING 7 NTH-VALUE 17
EXPRESSION 17
LEAST-NEGATIVE- MAKE-STRING- NTHCDR 8
FUNCTIONP 15
NORMALIZED- INPUT-STREAM 36 NULL 8, 40
SHORT-FLOAT 6 MAKE-STRING- NUMBER 40
GCD 3 LEAST-NEGATIVE- OUTPUT-STREAM NUMBERP 3
GENERIC-FUNCTION NORMALIZED- 36 NUMERATOR 4
40 SINGLE-FLOAT 6 MAKE-SYMBOL 42 NUNION 10

48
Common Lisp Quick Reference

ODDP 3 READ-LINE 30 SIXTH 8 TRACE 44


OF 21 READ-PRESERVING- SLEEP 20 TRANSLATE-
OF-TYPE 21 WHITESPACE 30 SLOT-BOUNDP 23 LOGICAL-
ON 21 READ-SEQUENCE 30 SLOT-EXISTS-P 23 PATHNAME 38
OPEN 36 READER-ERROR 29 SLOT-MAKUNBOUND TRANSLATE-
OPEN-STREAM-P 29 READTABLE 40 24 PATHNAME 38
OPTIMIZE 45 READTABLE-CASE 30 SLOT-MISSING 24 TREE-EQUAL 10
OR 19, 26, 39 READTABLEP 29 SLOT-UNBOUND 24 TRUENAME 38
OTHERWISE 19, 39 REAL 40 SLOT-VALUE 24 TRUNCATE 4
OUTPUT-STREAM-P REALP 3 SOFTWARE-TYPE 46 TWO-WAY-STREAM
29 REALPART 4 SOFTWARE-VERSION 40
REDUCE 14 46 TWO-WAY-STREAM-
REINITIALIZE- SOME 12 INPUT-STREAM 36
PACKAGE 40
INSTANCE 24 SORT 12 TWO-WAY-STREAM-
PACKAGE-ERROR 29
REM 4 SPACE 45 OUTPUT-STREAM
PACKAGE-ERROR-
REMF 16 SPECIAL 45 36
PACKAGE 28
REMHASH 14 SPECIAL- TYPE 42, 45
PACKAGE-NAME 41
REMOVE 13 OPERATOR-P 43 TYPE-ERROR 29
PACKAGE-
REMOVE- SPEED 45 TYPE-ERROR-DATUM
NICKNAMES 41
DUPLICATES 13 SQRT 3 29
PACKAGE-
REMOVE-IF 13 STABLE-SORT 12 TYPE-ERROR-
SHADOWING-
REMOVE-IF-NOT 13 STANDARD 26 EXPECTED-TYPE 29
SYMBOLS 42
REMOVE-METHOD 25 STANDARD-CHAR 40 TYPE-OF 39
PACKAGE-USE-LIST 41
REMPROP 16 STANDARD-CHAR-P 6 TYPECASE 39
PACKAGE-
RENAME-FILE 38 STANDARD-CLASS 40 TYPEP 39
USED-BY-LIST 41
RENAME-PACKAGE 41 STANDARD-GENERIC-
PACKAGEP 41
REPEAT 23 FUNCTION 40
PAIRLIS 9 UNBOUND-SLOT 29
REPLACE 13 STANDARD-METHOD
PARSE-ERROR 29 UNBOUND-
REQUIRE 42 40
PARSE-INTEGER 8 SLOT-INSTANCE 28
REST 8 STANDARD-OBJECT
PARSE-NAMESTRING UNBOUND-VARIABLE
RESTART 40 40
38 29
RESTART-BIND 28 STEP 45
PATHNAME 37, 40 UNDEFINED-
RESTART-CASE 28 STORAGE-
PATHNAME-DEVICE FUNCTION 29
RESTART-NAME 28 CONDITION 29
38 UNEXPORT 42
RETURN 20, 21 STORE-VALUE 28
PATHNAME- UNINTERN 41
RETURN-FROM 20 STREAM 40
DIRECTORY 38 UNION 10
REVAPPEND 9 STREAM-
PATHNAME-HOST 38
REVERSE 12 ELEMENT-TYPE 39 UNLESS 19, 21
PATHNAME-MATCH-P
ROOM 46 STREAM-ERROR 29 UNREAD-CHAR 30
29
ROTATEF 16 STREAM- UNSIGNED-BYTE 40
PATHNAME-NAME 38
ROUND 4 ERROR-STREAM 28 UNTIL 23
PATHNAME-TYPE 38
ROW-MAJOR-AREF 10 STREAM-EXTERNAL- UNTRACE 45
PATHNAME-VERSION
RPLACA 9 FORMAT 37 UNUSE-PACKAGE 41
38
RPLACD 9 STREAMP 29 UNWIND-PROTECT 20
PATHNAMEP 29
STRING 7, 40 UPDATE-INSTANCE-
PEEK-CHAR 30
STRING-CAPITALIZE 7 FOR-DIFFERENT-
PHASE 4 SAFETY 45 STRING-DOWNCASE 7 CLASS 24
PI 3 SATISFIES 39 STRING-EQUAL 7 UPDATE-INSTANCE-
PLUSP 3 SBIT 11 STRING-GREATERP 7 FOR-REDEFINED-
POP 9 SCALE-FLOAT 6 STRING-LEFT-TRIM 8 CLASS 24
POSITION 13 SCHAR 8 STRING-LESSP 7 UPFROM 21
POSITION-IF 13 SEARCH 13 STRING-NOT-EQUAL 7 UPGRADED-ARRAY-
POSITION-IF-NOT 13 SECOND 8 STRING- ELEMENT-TYPE 39
PPRINT 32 SEQUENCE 40 NOT-GREATERP 7 UPGRADED-
PPRINT-DISPATCH 34 SERIOUS-CONDITION STRING-NOT-LESSP 7 COMPLEX-
PPRINT-EXIT-IF-LIST- 29 STRING-RIGHT-TRIM PART-TYPE 6
EXHAUSTED 33 SET 16 8 UPPER-CASE-P 6
PPRINT-FILL 33 SET-DIFFERENCE 10 STRING-STREAM 40 UPTO 21
PPRINT-INDENT 33 SET- STRING-TRIM 8 USE-PACKAGE 41
PPRINT-LINEAR 33 DISPATCH-MACRO- STRING-UPCASE 7 USE-VALUE 28
PPRINT-LOGICAL- CHARACTER 31 STRING/= 7 USER-HOMEDIR-
BLOCK 33 SET-EXCLUSIVE-OR STRING< 7 PATHNAME 39
PPRINT-NEWLINE 33 10 STRING<= 7 USING 21
PPRINT-POP 33 SET-MACRO- STRING= 7
PPRINT-TAB 33 CHARACTER 31 STRING> 7
PPRINT-TABULAR 33 SET-PPRINT- V 36
STRING>= 7
PRESENT-SYMBOL 21 DISPATCH 34 VALUES 17, 39
STRINGP 7
PRESENT-SYMBOLS SET-SYNTAX- VALUES-LIST 17
STRUCTURE 42
21 FROM-CHAR 30 VARIABLE 42
STRUCTURE-CLASS
PRIN1 32 SETF 16, 42 VECTOR 11, 40
40
PRIN1-TO-STRING 32 SETQ 16 VECTOR-POP 11
STRUCTURE-OBJECT
PRINC 32 SEVENTH 8 VECTOR-PUSH 11
40
PRINC-TO-STRING 32 SHADOW 42 VECTOR-
STYLE-WARNING 29
PRINT 32 SHADOWING-IMPORT PUSH-EXTEND 11
SUBLIS 10
PRINT- 42 VECTORP 10
SUBSEQ 12
NOT-READABLE 29 SHARED-INITIALIZE SUBSETP 8
PRINT- 24 SUBST 10
NOT-READABLE- SHIFTF 16 WARN 27
SUBST-IF 10
OBJECT 28 SHORT-FLOAT 40 WARNING 29
SUBST-IF-NOT 10
PRINT-OBJECT 32 SHORT- WHEN 19, 21
SUBSTITUTE 13
PRINT-UNREADABLE- FLOAT-EPSILON 6 WHILE 23
SUBSTITUTE-IF 13
OBJECT 32 SHORT-FLOAT- WILD-PATHNAME-P
SUBSTITUTE-IF-NOT
PROBE-FILE 38 NEGATIVE-EPSILON 29
13
PROCLAIM 45 6 WITH 21
SUBTYPEP 39
PROG 20 SHORT-SITE-NAME 46 WITH-ACCESSORS 24
SUM 23
PROG1 19 SIGNAL 27 WITH-COMPILATION-
SUMMING 23
PROG2 19 SIGNED-BYTE 40 UNIT 44
SVREF 11
PROG∗ 20 SIGNUM 4 WITH-CONDITION-
SXHASH 14
PROGN 19, 26 SIMPLE-ARRAY 40 RESTARTS 28
SYMBOL 21, 40, 42
PROGRAM-ERROR 29 SIMPLE-BASE-STRING WITH-HASH-TABLE-
SYMBOL-FUNCTION
PROGV 20 40 ITERATOR 14
42
PROVIDE 42 SIMPLE-BIT-VECTOR WITH-INPUT-
SYMBOL-MACROLET
PSETF 16 40 FROM-STRING 37
18
PSETQ 16 SIMPLE- WITH-OPEN-FILE 39
SYMBOL-NAME 42
PUSH 9 BIT-VECTOR-P 10 WITH-OPEN-STREAM
SYMBOL-PACKAGE 42
PUSHNEW 9 SIMPLE-CONDITION 37
SYMBOL-PLIST 42
29 SYMBOL-VALUE 42 WITH-OUTPUT-
SIMPLE-CONDITION- SYMBOLP 41 TO-STRING 37
QUOTE 44
FORMAT- SYMBOLS 21 WITH-PACKAGE-
ARGUMENTS 29 SYNONYM-STREAM ITERATOR 42
RANDOM 4 SIMPLE-CONDITION- 40 WITH-SIMPLE-
RANDOM-STATE 40 FORMAT-CONTROL SYNONYM-STREAM- RESTART 28
RANDOM-STATE-P 3 29 SYMBOL 36 WITH-SLOTS 24
RASSOC 9 SIMPLE-ERROR 29 WITH-STANDARD-
RASSOC-IF 9 SIMPLE-STRING 40 IO-SYNTAX 30
RASSOC-IF-NOT 9 SIMPLE-STRING-P 7 T 2, 29, 40, 43 WRITE 32
RATIO 40 SIMPLE-TYPE-ERROR TAGBODY 20 WRITE-BYTE 32
RATIONAL 4, 40 29 TAILP 8 WRITE-CHAR 32
RATIONALIZE 4 SIMPLE-VECTOR 40 TAN 3 WRITE-LINE 32
RATIONALP 3 SIMPLE-VECTOR-P 10 TANH 3 WRITE-SEQUENCE 32
READ 30 SIMPLE-WARNING 29 TENTH 8 WRITE-STRING 32
READ-BYTE 30 SIN 3 TERPRI 32 WRITE-TO-STRING 32
READ-CHAR 30 SINGLE-FLOAT 40 THE 21, 39
READ- SINGLE- THEN 21
CHAR-NO-HANG 30 FLOAT-EPSILON 6 THEREIS 23 Y-OR-N-P 30
READ-DELIMITED- SINGLE-FLOAT- THIRD 8 YES-OR-NO-P 30
LIST 30 NEGATIVE-EPSILON THROW 20
READ-FROM-STRING 6 TIME 45
30 SINH 3 TO 21 ZEROP 3

49
lc
Common Lisp Quick Reference Revision 105 [2009-09-03]
Copyright © 2008, 2009 Bert Burgemeister
LATEX source: http://clqr.berlios.de
Permission is granted to copy, distribute and/or modify this document under the
terms of the GNU Free Documentation License, Version 1.2 or any later version
published by the Free Software Foundation; with no Invariant Sections, no Front-
Cover Texts and no Back-Cover Texts. http://www.gnu.org/licenses/fdl.html

You might also like