Hello! Function 'set' looses some of its data. It seems that there is a problem with comparison between lists and vectors:
user=> (count [nil false true 0 42 0.0 3.14 2/3 0M 1M \c "" "abc" 'sym :kw () '(1 2) [] [1 2] {} {:a 1 :b 2} #{} #{1 2}]) 23 user=> (set [nil false true 0 42 0.0 3.14 2/3 0M 1M \c "" "abc" 'sym :kw () '(1 2) [] [1 2] {} {:a 1 :b 2} #{} #{1 2}]) #{nil 0 0.0 0M "" {} #{} 2/3 () "abc" {:a 1, :b 2} (1 2) #{1 2} \c 3.14 42 sym true :kw false 1M} user=> (count (set [nil false true 0 42 0.0 3.14 2/3 0M 1M \c "" "abc" 'sym :kw () '(1 2) [] [1 2] {} {:a 1 :b 2} #{} #{1 2}])) 21 ; missing are [] and [1 2] user=> (set [()]) #{()} user=> (set [() []]) #{()} user=> (set [() [] {}]) #{{} ()} user=> (set [[] [1 2]]) #{[] [1 2]} user=> (set [[] [1 2] 1]) #{[] 1 [1 2]} user=> (set [[] [1 2] ()]) #{[] [1 2]} user=> (set [() [] [1 2]]) #{() [1 2]} What data types is sorted-set supposed to work on? When used with different data types, it errors out: http://clojure.org/data_structures user=> (doc sorted-set) ------------------------- clojure.core/sorted-set ([& keys]) Returns a new sorted set with supplied keys. user=> (sorted-set 4 2) #{2 4} user=> (sorted-set () []) java.lang.ClassCastException: clojure.lang.PersistentList$EmptyList cannot be cast to clojure.lang.IPersistentVector (NO_SOURCE_FILE:0) user=> (sorted-set nil false true 0 42 0.0 3.14 2/3 0M 1M \c "" "abc" 'sym :kw () '(1 2) [] [1 2] {} {:a 1 :b 2} #{} #{1 2}) java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.Number (NO_SOURCE_FILE:0) user=> (sorted-set '(1 2) 1) java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.Number (NO_SOURCE_FILE:0) user=> (sorted-set '(1 2) "abc") java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.String (NO_SOURCE_FILE:0) user=> (sorted-set "abc" #{1 2}) java.lang.ClassCastException: clojure.lang.PersistentHashSet cannot be cast to java.lang.Comparable (NO_SOURCE_FILE:0) user=> (sorted-set 42 #{1 2}) java.lang.ClassCastException: clojure.lang.PersistentHashSet cannot be cast to java.lang.Comparable (NO_SOURCE_FILE:0) It works when types are the same: user=> (sorted-set "z" "b") #{"b" "z"} user=> (sorted-set 42 2.0) #{2.0 42} user=> (sorted-set [2 3] [1]) #{[1] [2 3]} Frantisek --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---