Predicates

A predicate is a function that performs a test and returns either #t (true) or #f (false). Other dialects of Lisp use t for true and nil for false.

Note: Lisp functions that test predicate values, such as if, consider #f to be false and anything else to be true.

In Scheme, predicate names conventionally end in ?. In other dialects of Lisp, predicate names often end in p, e.g. numberp. Some commonly used predicates are:

     
(= x y ) (zero? x ) (number? x )
(<= x y ) (positive? x ) (integer? x )
(< x y ) (negative? x ) (rational? x )
(>= x y ) (odd? x ) (real? x )
(> x y ) (even? x ) (complex? x )
(exact? x ) (inexact? x )
(boolean? x ) (symbol? x )
(string? x ) (vector? x )
(char? x ) (pair? x )

Contents    Page-10    Prev    Next    Page+10    Index