Show Menu

Common Lisp Cheat Sheet by

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

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 desti­nation 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
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 desti­nation 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 (poly­mor­phism)
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, :acce­ssor, :init­arg, :init­form, :docu­men­tat­ion, :allo­cation
Returns the value of slot in the object (se­tf­-­able)
Binds a slot/a­ccessor to a symbol that can be used in its body

Download the Common Lisp Cheat Sheet

2 Pages
//media.cheatography.com/storage/thumb/boechat107_common-lisp.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

Like this cheat sheet? Check out our sponsors!

Readable.io is a collection of tools to make your writing better. More readable content means higher conversion rates and better reader engagement. Measure website and document readability, measure keyword density and more!

Click Here To Get Started!

 

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

          Closed-source Debugging with GDB Cheat Sheet
          oAuth End Points Cheat Sheet
          Object Oriented Design Cheat Sheet