Hi,

On Aug 10, 3:48 pm, David Sletten <da...@bosatsu.net> wrote:

> Notice how Clojure returns two different values here. Other Lisps (such as 
> Common Lisp) define FIRST/REST of the empty list to both be NIL (i.e., the 
> empty list itself). So it is common in other Lisps to test for the end of a 
> list using the equivalent of 'nil?', namely the function NULL. But in Clojure 
> if we are traversing a list and looking for the end, the correct function is 
> 'empty?'.
> (nil? '()) => false
> (empty? '()) => true

The idiomatic way to test for emptiness is actually to use seq. empty?
is actually defined as (empty? x) := (not (seq x)).

Sincerely
Meikel

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to