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


E.3.2 Sequence Predicate Functions

The following predicates test whether a Lisp object is an atom, whether it is a cons cell or is a list, or whether it is the distinguished object ‘nil’. (Many of these predicates can be defined in terms of the others, but they are used so often that it is worth having them.)

Object Predicates

Function: null object

This function returns ‘t’ if OBJECT is ‘nil’, and returns ‘nil’ otherwise.

NULL and NOT

This function is identical to ‘not’, but as a matter of clarity we use ‘null’ when OBJECT is considered a list and ‘not’ when it is considered a truth value

Function: atom object

This function returns ‘t’ if OBJECT is an atom, ‘nil’ otherwise. All objects except cons cells are atoms.

NIL

The symbol ‘nil’ is an atom and is also a list; it is the only Lisp object that is both.

Function: consp object

This function returns ‘t’ if OBJECT is a cons cell, ‘nil’ otherwise.

NIL

‘nil’ is not a cons cell, although it is a list.

List Predicates

Function: listp object

This function returns ‘t’ if OBJECT is a cons cell or ‘nil’. Otherwise, it returns ‘nil’.

Function: nlistp object

This function is the opposite of ‘listp’: it returns ‘t’ if OBJECT is not a list. Otherwise, it returns ‘nil’.

Function: proper-list-p object

This function returns the length of OBJECT if it is a proper list, ‘nil’ otherwise. In addition to satisfying ‘listp’, a proper list is neither circular nor dotted.

Sequence Predicates

Function: sequencep object

Predicate function to determine if OBJECT is a sequence type:

  • list
  • vector
  • string
  • bool-vector
  • char-table

See also ‘seqp’.

Array Predicates

Function: arrayp object

This function returns ‘t’ if OBJECT is an array (i.e., a vector, a string, a bool-vector or a char-table).


Next: Basic Sequence Functions, Previous: Building Cons Cells and Lists, Up: Sequence Functions   [Index]