On Wed, Jun 15, 2011 at 9:14 AM, CuppoJava <patrickli_2...@hotmail.com>wrote:
> There is one use of any? over some which hasn't been mentioned: > checking whether a list contains a nil. > > ie. (when (any? nil? xs) (do stuff)) > vs. (when (some nil? xs) (do stuff)) > > Actually, this case works with `some`. user=> (def any? (comp not not some)) #'user/any? user=> (any? nil? [1 nil 2]) true user=> (any? nil? [1 2]) false user=> (some nil? [1 nil 2]) true user=> (some nil? [1 2]) nil Comparing the general semantics, I can see no (useful) distinction between the two in `any?`s favor. `some` returns nil (falsy) on "failure" else truthy `any?` returns false (falsy) on "failure" else true (truthy) .. defining "failure" as all (pred x) in coll being falsy. Thanks, Ambrose -Patrick > > On Jun 14, 9:00 pm, Ken Wesson <kwess...@gmail.com> wrote: > > On Tue, Jun 14, 2011 at 12:29 PM, Ambrose Bonnaire-Sergeant > > > > <abonnaireserge...@gmail.com> wrote: > > > "some" is a poster boy for Clojure's well thought out truthyness > system, > > > this is a great example of the types of general functions it allows. > > > > Notably, with a map as first argument it returns the first (truthy) > > mapped value for any of the keys in a coll: > > > > (if-let [f (some fn-map [:super-override :override :normal])] > > (f args)) > > > > -- > > Protege: What is this seething mass of parentheses?! > > Master: Your father's Lisp REPL. This is the language of a true > > hacker. Not as clumsy or random as C++; a language for a more > > civilized age. > > -- > 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 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