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.

I expected the same thing at first, but the behavior appears to be
consistent with Java collections, so it's probably intended:

user=> (def s (java.util.TreeSet. (proxy [java.util.Comparator] []
(compare [a b] 0))))
#'user/s
user=> s
#<TreeSet []>
user=> (seq s)
nil
user=> (.add s 1)
true
user=> s
#<TreeSet [1]>
user=> (.add s 2)
false
user=> s
#<TreeSet [1]>


- Chris Perkins

-- 
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