On 22 February 2010 19:59, Sean Devlin <francoisdev...@gmail.com> wrote: > Generally when you have a "*-by" fn, you return the a sequence of > original values, not the mapped values (e.g. sort-by)
Which is precisely what both versions of distinct-by are doing. They return a sequence of values taken from the original collection, although determining which values those are involves calling a user-supplied function and performing a bunch of comparisons of the value thus obtained to values obtained from calls to said function at previous steps. E.g. (I'm repeating an example; this uses the second version of distinct-by): (distinct-by class [1 2 3 :a :b :c 'a 'b 'c]) ; => (1 :a a) whereas (distinct (map class [1 2 3 :a :b :c 'a 'b 'c]) ; => (java.lang.Integer clojure.lang.Keyword clojure.lang.Symbol) The primes one-liner using the nubBy-like version returns a list of numbers, whereas the "mapped values" are Booleans. Sincerely, Michał -- 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