Common LISP and Emacs LISP have the atom type predicate. Scheme and Clojure don't have it. http://hyperpolyglot.wikidot.com/lisp
Is there a design reason for this - or is it just not an essential function to include in the API?
Clojure has the coll?
(collection?) function, which is (sort of) the inverse of atom?
.
In the book The Little Schemer, atom?
is defined as follows:
(define (atom? x)
(and (not (pair? x))
(not (null? x))))
Noting that null
is not considered an atom, as other answers have suggested. In the mentioned book atom?
is used heavily, in particular when writing procedures that deal with lists of lists.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With