Predicates

A predicate in Lisp is a function that performs a test and returns either T (True) or NIL (False). Note: Lisp functions that test predicate values consider NIL to be False and anything else to be True. Predicate names often end in P. Some commonly used predicates are:


(SYMBOLP x)      True if x is a SYMBOL.

(ATOM x)         True if x is an ATOM
                 (anything besides a CONS).

(NULL x)         True if x is NIL.

(CONSP x)        True if x is a CONS cell.

(NUMBERP x)      True if x is a number.

(ZEROP x)        True if x is zero;
                 error if x not a number.

(MINUSP x)       True if x is negative;
                 error if x not a number.

Contents    Page-10    Prev    Next    Page+10    Index