Show Menu
Cheatography

[WIP] Hopefully, this cheatsheet lists the most common functions and macros, linking them to the "Common Lisp Hyper Spec".

Numbers

Parses an integer from a string
Truncates toward negati­ve/­pos­itive infinity
Rounds to the nearest integer
Modulu­s/r­ema­inder of a truncating division
Returns a new value (inc/d­ec)­rem­ented by a number
Macros to (inc/d­ec)­rement in place
=
,
/=
Mathem­atical value equality (types ignored)
>
,
>=
,
<
,
<=
Order comparison

Characters

 

Strings

Returns a formatted output string when the destin­ation is
nil

Sequences

Access elements with an integer index
Count the appear­ances of an element
Finds an item or returns
nil
The first index of an element
Returns the start position of a sequence in another sequence
Removes all the occurr­ences of an item
Replaces all occurr­ences of an item

Lists

Succes­sively applies a function to each element of a list
Like
mapcar
, but its function receives a cons cell instead of its element (there­fore, the function has access to the rest of the list)
Like
mapcar
, but the results are combined into a list
Like
mapcan
, but applied to
maplist

Vectors

 

Hash Tables

 
 

Things to remember

Object Oriented
All values in a Common Lisp program are instances of some class. Furthe­rmore, all classes are organized into a single hierarchy rooted at the class
T
.
Starting a project

Equality

Object identity (don't use with numbers or chars)
Considers equivalent two objects of the same class with the same numeric or char value
Lists with the same structure and contents, strings with the same characters
Ignores differ­ences in case or in numerical type (
1 == 1.0
)

Functions

Returns an anonymous function
Immedi­ately returns a value from a function (or a
block
)
Invokes a function from a function object
Works like
funcall
, but receives the arguments as a list
Different ways to capture function arguments

Standard Control Constructs

The else form is optional
Like
if
, but returns
nil
if the condition is falsy and evaluates multiple body forms
Like
when
, but executes its body only when the condition is falsy

IO

Produces formatted output to stdout when the destin­ation is
t
format
language
a
,
s
,
Interp­olate argument in human readable format; interp­olate as Lisp readable
%
,
&
Newline; newline if not at the beginning of a line

Object­-Or­iented

Defines an abstract operation (polymo­rphism)
Defines an implem­ent­ation of a generic function
Similar to an invocation to a super-­class method
New named class; some slot options are:
:reader
,
:writer
,
:accessor
,
:initarg
,
:initform
,
:docum­ent­ation
,
:alloc­ation
Returns the value of slot in the object (
setf
-able)
Binds a slot/a­ccessor to a symbol that can be used in its body
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          oAuth End Points Cheat Sheet
          Object Oriented Design Cheat Sheet
          ISTQB Test Automation Engineering Cheat Sheet