I am learning the concept of sequence and nil in Clojure. This was the result of a small experimentation.
1:6 user=> (first '())
nil
1:7 user=> (rest '())
()
1:8 user=> (first (rest '()))
nil
Does this mean that ‘() is actually a sequence of nils?
If you want to test whether the “rest” of a collection is empty, use
next.“nil-punning” (treating an empty collection/seq and
nilas the same thing) was removed last year in favor of fully-lazy sequences. See here for a discussion leading up to this change.