On Apr 9, 2014, at 12:11 AM, Simon Brooke <still...@googlemail.com> wrote: > 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.
I think that's a bit misleading. If you look at the source of every? it checks (nil? (seq coll)) and returns true. In other words, it's not that "Nil, generally speaking, is the empty list", it's more to do with the idiomatic use of seq to determine whether a collection is an empty sequence or not. We typically see: (if (seq coll) ;; process coll as a non-empty sequence with first / rest ;; we're "done" - nothing to process ) I don't consider that a "hard to explain design decision" but it is a standard idiom that is initially unfamiliar to many people coming from certain other languages... Sean Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880)
signature.asc
Description: Message signed with OpenPGP using GPGMail