On 26 April 2015 at 06:08, Colin Taylor <colin.tay...@gmail.com> wrote:
> So I was thinking of: > > user=> (any? true? [false true false]) > true > user=> (any? even? [1 2 3]) > true > ; touch "3" > user=> (any? #(.exists %) [(file "1") (file "2") (file "3")]) > true > Those examples all work with `some` as well: user=> (some true? [false true false]) true user=> (some even? [1 2 3]) true user=> (some #(.exists %) [(file "1") (file "2") (file "3")]) true Some motivations > > - my main one is Java interop where use of non booleans would be weird > That's a valid reason, but it's not a common enough case to justify its own function, IMO. Also, in cases where the type matters, having to add an explicit `boolean` onto the front makes the code clearer. > - similarly it is nicer for APIs to return booleans than a value that is > kinda arbitrary and potentially non deterministic. I might recall Rich > saying something like that..? > The `some` function isn't unusual. A lot of boolean logic functions in Clojure return a "truthy" or "falsey" value, rather than true or false explicitly. user=> (and true 1) 1 user=> (and nil true) nil user=> (or true 1) 1 > - the symmetry of `any` joining `not-any`, `every` and `not-every`. > That's true, but then you have two functions, `some` and `any?`, that do the same thing under most circumstances. That strikes me as somewhat confusing, especially as `any?` is essentially a niche-case operation. - James -- 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.