Thanks for explanation, all!
Frantisek
On 20 Ún, 20:57, Jason Wolfe wrote:
> It probably does an "identical?" call on a pair before calling
> compare, for efficiency. In other words, it may "work" on non-
> comparable types, but only when passed n instances of the exact same
> object:
>
> user
It probably does an "identical?" call on a pair before calling
compare, for efficiency. In other words, it may "work" on non-
comparable types, but only when passed n instances of the exact same
object:
user> (sorted-set '(1) '(1))
; Exception
user> (let [x '(1)] (sorted-set x x))
#{(1)}
This
It looks that it is more complicated than that:
user=> (sorted-set () ())
#{()}
user=> (sorted-set {} {})
#{{}}
user=> (sorted-set #{} #{})
#{#{}}
Frantisek
On 20 Ún, 20:33, Vincent Foley wrote:
> I'm pretty sure that sorted-set works only with values that are
> instances of a class that implem
I'm pretty sure that sorted-set works only with values that are
instances of a class that implements Comparable.
user=> (instance? Comparable [])
true
user=> (instance? Comparable {})
false
user=> (instance? Comparable ())
false
user=>
On Feb 20, 2:21 pm, Frantisek Sodomka wrote:
> sorted-set
sorted-set works for vectors, but doesn't work for lists, maps and
sets:
user=> (sorted-set [1 4])
#{[1 4]}
user=> (sorted-set [1 4] [1 4])
#{[1 4]}
user=> (sorted-set [4 1] [1 4])
#{[1 4] [4 1]}
user=> (sorted-set '(1 4))
#{(1 4)}
user=> (sorted-set '(1 4) '(1 4))
java.lang.ClassCastException: c