Lisp Cheat Sheet



To help you use a mental status exam as an assessment tool, we’ve created a cheat sheet. The following checklist is meant to be easy to read, so you can use it as a quick reference. Although you can customize a mental status exam to suit each client, you’ll generally want to focus on the categories in this checklist. A cheat sheet providing Common Lisp basics & synthax in the form of a.lispfile made of commented examples. (For people who already know about programming concepts).

Common Lisp is a general-purpose programming language with functions as first-class citizens. Don't worry about being purely functional, Lisp is Object Oriented too. CLOS is a very powerful object-oriented system!

Useful definitions

The Common Lisp lingo is quite unique:

  • Package: Basically a namespace, a place for symbols to live
  • System: Basically a Library. A bunch of code plus some instructions how it should be treated, for example which other systems it depends on, what should be loaded and/or compiled first, etc. Not in ANSI lisp but widespread. The most common system definition tool is ASDF.
  • Modules: Deprecated and implementation-dependent
  • Quicklisp: Like NPM or Ruby Gems for ASDF Systems.

Variables

You can define, set and get variables as follows: Drivers maingear.

The 'earmuffs' are an optional convention, it means 'warning, this can change'.

setf and getf can be used for structs, object and pretty much everything.

Equality Predicates

  • (eq x y) is true if and only if x and y are the same identical object.
  • (eql x y) is true if its arguments are eq, or if they are numbers of the same type with the same value, or if they are character objects that represent the same character.
  • (equal x y) is true if its arguments are structurally similar (isomorphic) objects. A rough rule of thumb is that two objects are equal if and only if their printed representations are the same.
  • (equalp x y) is true if they are equal; if they are characters and satisfy char-equal, which ignores alphabetic case and certain other attributes of characters; if they are numbers and have the same numerical value, even if they are of different types; or if they have components that are all equalp.

Format

format is like C's printf. It will replace some wildcards in the string with the values passed. The most common use case are either print something to the screen or return the value as a string.

~A stands for Anything, it works most of the time and is the most common wildcard used. See this chapter of Practical Common Lisp for more on this.

Functions

Objects

More info: Brief Guide to CLOS.

Data Structures

Conditions and Restarts

You can use conditions pretty much the same way you would use a Try/Catch:

Instead of using handler-case you can use restart-case and specify how thaterror is restarted, so callers can choose a restart and abstract the implementation away

Callers (either direct or indirect) of a function which provides restarts can pick the restart they want by wrapping code in a handler-bind macro. handler-bind associates a condition with it's restart:

If you are not sure the restart will be there you can check by using find-restart:

You can find more info on Conditions and Restarts in this chapter of the awesome book: Practical Common Lisp.

Making errors play nice with the debugger

Use :report for that:

Sheet
  • Install Roswell
  • Install Spacemacs
  • Enable the Common Lisp config

Lynx studio sound cards & media devices driver download. For each project, you'll need to add it to ASDF's central registry. You can do this by adding something like this to your ~/.sbclrc file (.roswell/init.lisp if you are using Roswell):

Lascar others driver download for windows 10. Because it's a hassle to do this everytime you make a new project, if you use a UNIX-y OS you can use a dedicated folder to contain all ASDF system definitions (.asd files)

Your central repository definition would then look like this:

Libraries

  • You can use Quickproject to make new projects
  • You can use rove for testing
  • Alexandria is an extension to Common Lisp to provide some overall goodies, kind of like ActiveSupport for Ruby

Lisp Cheat Sheet Free

You can use break and step and trace for debugging. Remember to enable the debug settings in the Lisp initialization file.

Once in the debugging SLIME session, you can step in, step over, and press e for evaluating a Lisp expression. More info here.

For break, just put it as a regular breakpoint in code. For step, use it to call a function:

If you want to try some print debugging you can drop a (inspect ..) in the code and the execution will stop there and you will able to inspect whatever you want.

Lisp Slime Cheat Sheet

  • More on CLOS (Common Lisp Object System)
  • Practical Common Lisp very good and in-depth introduction to Common Lisp
  • Debugging how to step-in debug your Common Lisp programs