Okay, excellent counterexample for some. I understand that behavior now. I guess I should focus on my main point, changing/aliasing the name to some? to be consistent with every?
On May 26, 9:34 am, Laurent PETIT <laurent.pe...@gmail.com> wrote: > Hi, > > (comp first filter) and some are not equivalent. > > Consider this less simple case: > > user=> (defn negate-or-nil [x] (when (even? x) (- x))) > #'user/negate-or-nil > user=> (first (filter negate-or-nil [1 2 3])) > 2 > user=> (some negate-or-nil [1 2 3]) > -2 > user=> > > some returns the result of the predicate, filter returns the seq item > for which predicate matches. > > Concerning the result of some, it seems better to return a more > meaningful value, because it still can be used as logical true, e.g. > in an if or when construct ... > > 2009/5/26 Sean Devlin <francoisdev...@gmail.com>: > > > > > To add to my own post: > > > There is also a discrepancy in what is returned from the two > > > (some identity [1 2 3]) -> 1 > > (every? identity [1 2 3]) -> true > > > I would expect the following to occur > > > (some identity [1 2 3]) -> true > > > Granted, it's all the same to an if statement. However, current > > behavior of some has the added use: > > > (first (filter identity [1 2 3])) -> 1 > > (some identity [1 2 3]) -> 1 > > > Is the equivalence a fluke, or is this by design? Is there any > > promise that some will continue to behave this way in the future? If > > so, it seems like a bad alias for (first (filter...)) > > > Just more to discuss > > > On May 26, 9:02 am, Sean Devlin <francoisdev...@gmail.com> wrote: > >> I just noticed a quirk in the core API. The some and every? functions > >> have different naming conventions. Is there a reason for this? If > >> not I think renaming/creating an alias some? would be very helpful. --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---