Next: Accessing Elements of Lists, Previous: Lists and Cons Cells, Up: Lists [Contents][Index]
5.2 Predicates on ListsThe 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.)
This function returns t
if object is a cons cell, nil
otherwise. nil
is not a cons cell, although it is a list.
This function returns t
if object is an atom, nil
otherwise. All objects except cons cells are atoms. The symbol nil
is an atom and is also a list; it is the only Lisp object that is both.
(atom object) ≡ (not (consp object))
This function returns t
if object is a cons cell or nil
. Otherwise, it returns nil
.
This function is the opposite of listp
: it returns t
if object is not a list. Otherwise, it returns nil
.
(listp object) ≡ (not (nlistp object))
This function returns t
if object is nil
, and returns nil
otherwise. This function is identical to not
, but as a matter of clarity we use not
when object is considered a truth value (see not
in Constructs for Combining Conditions) and null
otherwise.
This function returns the length of object if it is a proper list, nil
otherwise (see Lists and Cons Cells). In addition to satisfying listp
, a proper list is neither circular nor dotted.
(proper-list-p '(a b c)) ⇒ 3
(proper-list-p '(a b . c)) ⇒ nil
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4