Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scheme and Clojure don't have the atom type predicate - is this by design?

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?

like image 755
hawkeye Avatar asked Aug 12 '10 11:08

hawkeye


2 Answers

Clojure has the coll? (collection?) function, which is (sort of) the inverse of atom?.

like image 94
Stuart Sierra Avatar answered Sep 29 '22 13:09

Stuart Sierra


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.

like image 21
Óscar López Avatar answered Sep 29 '22 12:09

Óscar López