On 25.07.2013 11:19, gixxi wrote:
> Consider the following record definition, a respective record instance
> as well as a sorted tree set with a custom comparator sorting first the
> :visited property and the by the :dist property of the record.
>
> (defrecord RDistance
> [node dist visited])
>
> (def d (RDistance. "foo" 1 0))
>
> (def tree (sorted-set-by (comparator (juxt :visited :dist)) d))
>
>
> I expect conj d again to the set would change the set, but doing so in
> the repl results in the set containing two equal elements
>
> user=> (conj tree d)
> #{#user.RDistance{:node "foo", :dist 1, :visited 0}
> #user.RDistance{:node "foo", :dist 1, :visited 0}}
>
> What is the problem?
The argument to `comparator` should be a function of two arguments that
returns a boolean value:
http://clojuredocs.org/clojure_core/1.2.0/clojure.core/comparator
--
Timo
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.