On Tuesday, 8 April 2014 07:08:56 UTC+1, Jeff Mad wrote: > > Hi, > I am new to Clojure, so please forgive me if this does not make sense. > > I was surprised to find out in the REPL that every? returns true if you > pass in an empty or nil collection. > > user=> (every? #(= 77 %) nil) > > true > > user=> (every? #(= 77 %) '()) > > true > Every item in the list () is equal to 77, so of course it returns true. There are no items in the list () that are not equal to 77.
Clojure is a bit muddled about nil. Nil, generally speaking, is the empty list - which is why (every? #(= 77 %) nil) is true. But in Clojure, it's not true that (= nil ()). There's no point in saying this is a mistake. But it does result in some very hard to explain design decisions. -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.