I noticed strange behavior in the sort function, I was sorting key
value tuples and ran into the following:

when sorting 2 item vectors such as [1 [1 2 3]] sort works fine:
(println
    (sort
        (map
           (fn [x] [(int (* (Math/random) 10)) x]) (for [x (range 4)]
[1 2 3]))))

output:
([6 [1 2 3]] [6 [1 2 3]] [6 [1 2 3]] [6 [1 2 3]])

however, if the second item is a list, e.g:
(println
    (sort
        (map
           (fn [x] [(int (* (Math/random) 10)) x]) (for [x (range
100)] `(1 2 3)))))

the following exception can occur, this happens more frequently for
larger ranges, for range of 4, it may or may run and produce the
result, however with a range of 100 the exception occurs consistently:

Exception in thread "main" java.lang.RuntimeException:
java.lang.ClassCastException: clojure.lang.LazyCons (gen.clj:60)
        at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:2684)
        at clojure.lang.Compiler.compile(Compiler.java:4564)
        at clojure.lang.RT.compile(RT.java:362)
        at clojure.lang.RT.load(RT.java:404)
        at clojure.lang.RT.load(RT.java:376)




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

Reply via email to