Here's the source for sorted-set-by:

(defn sorted-set-by
  "Returns a new sorted set with supplied keys, using the supplied
comparator."
  ([comparator & keys]
   (clojure.lang.PersistentTreeSet/create comparator keys)))

This is because your comparator is saying that everything is equal.
PersistentTreeSet delegates a lot of work to PersistentTreeMap, so the
object is happily replacing every element when the comparator is zero.

I'm not sure if this is a bug or the intended behavior...  I'm leaning
toward the latter, even though it's confusing.

Sean

On Apr 16, 8:25 am, Razvan <gigi.clan...@gmail.com> wrote:
> Hi,
>
> Is this the intended behavior?
>
> (sorted-set-by (constantly 0) 1 2 3 4) returns #{1}.
>
> I would expect the set to contain all the elements, and the comparator
> to only affect sort order.
>
> Razvan
>
> --
> 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 
> athttp://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

Reply via email to