Tests on cons
(cons? item ) tests whether item is a cons, i.e. non-empty part of a list or tree structure. cons? is not a built-in Clojure function; do (load-file "cs378.clj")
(empty? item ) tests whether item is empty, i.e. either nil or '() .
These special tests are needed because Clojure is inconsistent in the ways it represents list structure: nil and '() are different.
Clojure error messages can be confusing since they come from the Java Virtual Machine rather than Clojure.
user=> (first 3.14)
Execution error ...
Don't know how to create ISeq from:
java.lang.Double
Translated into English, this means: you tried to do first
or rest on something that is not a cons; it was
(in this case) a Double. So, test cons? before
doing first or rest.