Next: , Previous: , Up: Functions   [Contents][Index]

5.9.4 Predicate Functions

In Lisp, a function which returns a boolean ‘true’ or boolean ‘false’ value is called a predicate. As is the convention in Lisp a value of () means false, anything else means true. The symbols nil and t are often used to represent constant false and true values (see nil and t).

Another Lisp convention is that the names of predicate functions should name the quality that the predicate is testing followed by either a ‘p’ or ‘-p’ string. The ‘p’ variant is used when the first string does not contain any hyphens.

For example, the predicate to test for the quality const-variable (a variable which has a constant value, see Defining Variables) is called const-variable-p. On the other hand the predicate to test for the quality cons (a Cons cell) is called consp.