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: clojure.lang.PersistentList cannot be
cast to java.lang.Comparable (NO_SOURCE_FILE:0)

user=> (sorted-set {:a 1 :b 2})
#{{:a 1, :b 2}}
user=> (sorted-set {:a 1 :b 2} {:a 1 :b 2})
java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot
be cast to java.lang.Comparable (NO_SOURCE_FILE:0)

user=> (sorted-set #{1 2})
#{#{1 2}}
user=> (sorted-set #{1 2} #{1 2})
java.lang.ClassCastException: clojure.lang.PersistentHashSet cannot be
cast to java.lang.Comparable
(NO_SOURCE_FILE:0)

---
How does sorted-set know which value is bigger or smaller? Could this
functionality be exported?
user=> (sorted-set [4 3] [2 1])
#{[2 1] [4 3]}
user=> (> [4 3] [2 1])
java.lang.ClassCastException: clojure.lang.LazilyPersistentVector
cannot be cast to java.lang.Number (NO_SOURCE_FILE:0)
user=> (= [4 3] [2 1])
false

user=> (> "xyz" "abc")
java.lang.ClassCastException: java.lang.String cannot be cast to
java.lang.Number (NO_SOURCE_FILE:0)

Thank you, Frantisek
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to