On Thu, Feb 3, 2011 at 2:31 AM, Meikel Brandmeyer <m...@kotka.de> wrote: > Hi, > > On 3 Feb., 08:04, Petr Gladkikh <petrg...@gmail.com> wrote: > >> Should not it be empty colection instead? >> It seems odd to me since it is inconsistent and forces to consider one >> more case (nil or collection). > > It is consistent. There is a difference between () and nil. () is the > empty list. However there is no "empty sequence."
According to Clojure 1.2 itself, there is: user=> (seq? ()) true The empty list is both, it seems. :) However, user=> (seq ()) nil so (if-let [s (seq x)] ...) still works to separate empty lists (indeed, all empty colls) from non-empty ones. Also of interest is user=> (seq? nil) false The sequence functions accept it nonetheless, and most accept vectors, sets, and maps as well. In particular: user=> (nth nil 42) nil user=> (nth nil 42 "not found") "not found" -- 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