

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Summarized below are several basic functions used in the Lisp programming language. In some cases, both a short form and a long form are given (separated by or ).
Basic List Operations (car X) - return the head (first element) of the list X (cdr X) - return the tail of the list X (X with the first element removed) (cons X Y) - return the list created by inserting the list X onto the front of list Y (append X Y) - return the list created by concatenating lists X and Y (list X 1 X 2 ... Xn) - return the list created by concatenating lists X 1 , X 2 , ... Xn (โ X) or (quote X) - return the list X (treated as a literal)
Arithmetic Operations (+ E 1 E 2 ... En) - return E 1 +E 2 +...^ +En (โ E 1 E 2 ... En) - return E 1 โE 2 โ...^ โEn (* E 1 E 2 ... En) - return E 1 *E 2 *... *En (/ E 1 E 2 ... En) - return E 1 โ E 2 โ...^ โ En (1+ X) - return X + 1 (1โ X) - return X โ 1
Relational Operations (zerop X) - if X = 0 then return T else return NIL ( relation X Y) - if X relation Y then return T else return NIL ( relation is =, /=, <, <=, >, >=) (equal X Y) - if X = Y then return T else return NIL (eq X Y) - if X and Y are the same object, then return T else return NIL
Logical Operations (and X 1 X 2 ... Xn) - return X 1 ฮ X 2 ฮ ... ฮ Xn (or X 1 X 2 ... Xn) - return X 1 V X 2 V ... V Xn (not X) - return ยฌ X
Control Operations (setq X Y) - assign the value of Y to X and return the value of Y (set X Y) - same as setq except that X can be a computed value (cond (test 1 expression 1 ) if test 1 then return expression 1 (test 2 expression 2 ) else if test 2 then return expression 2 ... ... (testn expressionn)) else if testn then return expressionn (print X) - print X
Function Manipulation Operations (defun F (X 1 X 2...^ Xn) E) - define function F on arguments X 1 , ..., Xn to be the value of expression E (apply F L) - apply the function denoted by F to the argument list L (eval E) - evaluate the expression denoted by E (prog (X 1 X 2...^ Xn) E 1 E 2...^ Em) - define local variables X 1 , ..., Xn to be used in evaluating expressions E 1 , ..., Em, the value of the last being returned as the value of the PROG expression (return E) - return the value of E (usually used in a prog expression)