consp
type: predicate function (subr) location: built-in source file: xlbfun.c Common LISP compatible: yes supported on: all machines
SYNTAX
(consp <expr> )
<expr> - the expression to check
DESCRIPTION
The CONSP predicate checks if the <expr> is a non-empty list. T is returned if <expr> is a list, NIL is returned otherwise. Note that if the <expr> is NIL, NIL is returned.
EXAMPLES
(consp '(a b)) ; returns T - list (consp '(a . b)) ; returns T - dotted pair list (consp #'defvar) ; returns NIL - closure - macro (consp (lambda (x) (print x))) ; returns NIL - closure - lambda (consp NIL) ; returns NIL - NIL (consp #(1 2 3)) ; returns NIL - array (consp *standard-output*) ; returns NIL - stream (consp 1.2) ; returns NIL - float (consp #'quote) ; returns NIL - fsubr (consp 1) ; returns NIL - integer (consp object) ; returns NIL - object (consp "str") ; returns NIL - string (consp #'car) ; returns NIL - subr (consp 'a) ; returns NIL - symbol
NOTE: When applied to CONSP, NIL - the empty list - returns a NIL. NIL or '() is used in many places as a list-class or atom-class expression. Both ATOM and LISTP, when applied to NIL, return T. If you wish to check for a list where an empty list is still considered a valid list, use the LISTP predicate.