IV. COND

COND is an unusual function which may take any arbitrary number of arguments. Each argument is called a clause, and consists of a list of exactly two S-expressions. We will call the first S-expression in a clause a condition, and the second S-expression a result. Thus, a call to COND looks like this:
(COND
	(condition1   result1 )
	(condition2   result2 )
	. . .

(T resultN ) )

The value returned by COND is computed as follows: if condition1 is true (not NIL), then return result1; else if condition2 is true then return result2; else if ...; else return resultN. In most LISP systems, it is an error if none of the conditions are true, and the result of the COND is undefined. For this reason, T is usually used as the final condition.

Previous page First page Next page


Copyright © 1995 by David Matuszek
All rights reserved.
Last updated July 15, 1995