Useful Common Lisp Functions
Predicates
- LISTP - returns t if argument is a list
- ATOM - returns t if arg is an atom, nil otherwise
- NULL - returns t if argument is the null list
- EQ - returns t if two arguments are identical.
- EQUAL - returns t if two arguments have same elements
- MINUSP - returns t if arg is a negative number
- PLUSP - returns t if arg is a positive number
- NUMBERP - returns t if arg is a number
- ZEROP - returns t if arg is the number 0
Logic functions
- AND - evaluates arguments in turn, until one returns false or
last argument is reached. returns value of last argument evaluated
- OR - evaluates arguments in turn, until one returns true or last
argument is reached. Returns value of last argument evaluated
- NOT - returns t if arg is nil, otherwise nil.
List functions
- CAR - returns the head of a list
- CDR - returns the tail of the list
- CONS - add an element to a list, eg (cons '(a b) '(c d)) = ((a
b) c d)
- APPEND - joins to lists, eg (append '(a b) '(c d)) = (a b c d).
- MEMBER - returns the list that begins with the first argument,
eg (member 'a '(b c a d)) returns (a d)
- CADR - returns the car of the cdr of a list (ie the second
element)
- CADDR - returns the car of the cdr of the cdr of a list (ie the
third element)
- REVERSE - (reverse '(a (b c) d)) = (d (b c) a)
Defining functions
- DEFUN - (defun somefun(a b) ( ... )) defines a function somefun
that has two arguments
- EVAL - evaluates its argument
Numeric functions
- MAX - maximum in the list
- MIN - minimum in the list
- ABS - absolute value
- SQRT - square root
- +, -, *, /,>,>=, ...
Others
- (BYE)
- LOAD - (LOAD "fn.lsp")
- HELP - (help 'car)
- TRACE - (trace aaa bbb) Causes all calls to aaa and bbb to be
traced
- PRIN1 - prints its argument, without a newline.
- PRINT - prints its argument and then a newline.
- READ - reads and returns an S-expression.
Last modified on Tuesday, 24-Nov-2003