next up previous
Contents Next: Logical Operators: And Up: More Predicates and Previous: Equality Predicates

Checking for NIL

The predicates null and not act identically. Good programming style dictates that you use null when the semantics of the program suggest interest in whether a list is empty, otherwise use not:

>(null nil)
T

>(not nil)
T

>(null ())
T

>(not ())               ;;preferable to use null
T

>(null '(a s))
NIL

>(not '(a s))           ;;preferable to use null
NIL

>(not (= 1 (* 1 1)))
NIL

>(null (= 1 (* 1 1)))   ;;preferable to use not
NIL



© Colin Allen & Maneesh Dhagat
November 1999