Unterlagen PSPP HS15
Common Lisp Quick Reference
Practical Common Lisp
The Common Lisp Cookbook
COMMON LISP: A Gentle Introduction to Symbolic Computation (PDF)
Land of LISP, No Starch Press github Source Code
Learning Lisp for CMPT 310
Implementation Notes for GNU CLISP
CLiki Common Lisp wiki
Using and Installing CLISP
Eclipse Common Lisp
CLiki: Development – Editor/IDE support
CLiki: Cusp Eclipse IDE plugin
CLiki: Steel Bank Common Lisp (SBCL)
Dandelion – Eclipse Lisp Plugin Eclipse Update
Develop Lisp applications using the Cusp Eclipse plug-in
Does anyone have a CUSP plugin for Eclipse (Common Lisp)
Getting Cusp running from source
What are the good “rich” IDEs for Lisp?
LispWorks Personal Edition (free)
Clozure Common Lisp
5.3 The Data and Control Flow Dictionary
14.2 The Conses Dictionary
LIST (System Class)
PROGN (Special Operator)
LET (Special Operator)
FLOOR, CEILING, TRUNCATE, ROUND (Function)
MAPCAR, MAPLIST (Function)
Top Level Loop
lisp, how to eliminate restarts
The following restarts are available:
USE-VALUE :R1 Input a value to be used instead.
ABORT :R2 Abort debug loop
ABORT :R3 Abort debug loop
ABORT :R4 Abort debug loop
ABORT :R5 Abort main loop
Break 4 > :q
- a. one of possibly several objects that are the result of an evaluation.
- b. (in a situation where exactly one value is expected from the evaluation of a form) the primary value returned by the form.
- c. (of forms in an implicit progn) one of possibly several objects that result from the evaluation of the last form, or nil if there are no forms.
- an object associated with a name in a binding.
- (of a symbol) the value of the dynamic variable named by that symbol.
- an object associated with a key in an association list, a property list, or a hash table.
- more than one value.
- “The function truncate returns multiple values.”
- a variable number of values, possibly including zero or one.
- “The function values returns multiple values.”
- a fixed number of values other than one.
- “The macro multiple-value-bind is among the few operators in Common Lisp which can detect and manipulate multiple values.”
form/forms vs. datum
Forms and the Top-Level Loop
Definition of “lisp form”?
The things which you type to the LISP interpreter are called forms; the LISP interpreter repeatedly reads a form, evaluates it, and prints the result. This procedure is called the read-eval-print loop.
Some forms will cause errors. After an error, LISP will put you into the debugger so you can try to figure out what caused the error. LISP debuggers are all different; but most will respond to the command “help” or “:help” by giving some form of help.
In general, a form is either an atom (for example, a symbol, an integer, or a string) or a list. If the form is an atom, LISP evaluates it immediately. Symbols evaluate to their value; integers and strings evaluate to themselves. If the form is a list, LISP treats its first element as the name of a function; it evaluates the remaining elements recursively, and then calls the function with the values of the remaining elements as arguments.
For example, if LISP sees the form (+ 3 4), it treats + as the name of a function. It then evaluates 3 to get 3 and 4 to get 4; finally it calls + with 3 and 4 as the arguments. The + function returns 7, which LISP prints.
form = datum + program, that can be evaluated without an error.
This is a lisp datum, it’s a list of 3, 4 and 1. This is not a form however as trying to evaluate it does not result into another datum. But rather an error:
(3 4 1)
This is a datum, and a form, also called a ‘normal form’ or a ‘self-evaluating datum’, it evaluates to itself:
This is a compound form, evaluating it results into the normal form 8:
(+ 3 4 1)
Apart from normal forms and compound forms, compound forms can be subdivided into procedure calls and special forms (also called syntax) but more properly, the head of a special form is the syntax, as in:
(if (oddp 2) (print "me") (print "or me"))
This is a special form because it’s head is syntax, and not a procedure, the only difference between procedure calls and special forms is that procedure calls see all of the arguments of the form as forms in itself and try to evaluate it first and special forms not necessarily do that. As we understand, only the second and fourth member of this compound form get evaluated, the first member is syntax, and the third is discarded in this case.
As we know for instance this code. But it’s not a form in Common Lisp:
((a 1) (b 2))
(let ((a 1) (b 2)) (+ a b))
Is a special form, it does not evaluate its second member, and evaluates its third member in a different fashion than what would be expected if it was not a special form. That is, a and b as subforms of its third form have a different binding. let in this case is a syntactic keyword that signals the special form.
arguments &optional, &rest and &key
&optional = optional argument(s)
&rest = rest arguments(s)
Werden in eine eigene Liste zusammengefasst.
&rest steht an letzter Stelle, nach notwendigen
und optionalen Parametern
&key = key arguments
Statt Parameter-Reihenfolge über Key/Value
(defun foo (&key a b c) (list a b c))
(foo) ==> (NIL NIL NIL)
(foo :a 1) ==> (1 NIL NIL)
(foo :b 1) ==> (NIL 1 NIL)
(foo :c 1) ==> (NIL NIL 1)
(foo :a 1 :c 3) ==> (1 NIL 3)
(foo :a 1 :b 2 :c 3) ==> (1 2 3)
(foo :a 1 :c 3 :b 2) ==> (1 2 3)
keyword or keys in arguments (colons 🙂
What is the colon (:) in Emacs lisp?
Why colons precede variables in Common Lisp
(list) vs. (values)
Most forms create only one value
A form typically returns only one value. Lisp has only a small number of forms which create or receive multiple values.
Normally multiple values are not used. Special forms are required both to produce multiple values and to receive them. If the caller of a function does not request multiple values, but the called function produces multiple values, then the first value is given to the caller and all others are discarded; if the called function produces zero values, then the caller gets nil as a value.
Constructs for Handling Multiple Values
Essential Multiple Values
alues function in Common Lisp
`values` vs `list` for returning multiple values from Lisp form
(cons) vs. Consing
Why is consing in Lisp slow?
Object-Oriented equivalent of LISP's progn function?
(setq) vs. (setf)
Lisp style: setq vs. setf
(set symbol foo) = set symbol to foo (Deprecated!)
(setf place form) = set place to primary values of forms (Macro to setq)
(setq symbol form) = set symbol to primary values of form
Tips on Writing Comments
> (+ 2 3)
> (print "hello world")
> (defun hello-name (name) (format nil "Hello ~A" name))
> (hello-name 'matt)
> (load "power.lisp")
;; Loading file power.lisp
;; Loaded file power.lisp
> (power 3 4)
Why 'x' doesn't be recognized?
> (defun beispiel (a b c) (list a b c))
> (beispiel 1 2 3)
(1 2 3)
> (beispiel x y z)
*** - SYSTEM::READ-EVAL-PRINT: variable X has no value
How to return a value?
> (defun test123 ()
> (defun test123 ()