II. Basic functions

DEFUN is used to define new functions. It takes three parameters, which are implicitly quoted (see below): (1) the name of the function, as an atom; (2) the formal parameter list of the function, as a list of atoms; and (3) an S-expression representing the body of the function. DEFUN defines the new function and return as its value the name of the function. (Note: some LISP systems use some other function, such as DEFQUOTE, to define functions.)

QUOTE takes a single S-expression as a parameter, and returns that S-expression, unevaluated, as its result.

The CAR of a nonempty list is the first element (S-expression) in that list.

The CDR of a nonempty list is the list with its first element removed.

The CONS of an S-expression to a list is the list with the S-expression inserted at the beginning, as a new first element. Note that the CAR of this new list is the given S-expression, while the CDR is the original list.

EQ compares two atoms for equality (identity) and returns "true'' if the atoms are the same, NIL if they are different.

ATOM of an S-expression is "true'' if the S-expression is an atom, and NIL otherwise.

NULL of an S-expression is "true'' if the S-expression is the empty list (that is, NIL), and NIL otherwise.

Previous page First page Next page


Copyright 1995, 2000 by David Matuszek
All rights reserved.
Last updated October 27, 2000