Hmmm, that is weird ... I would expect the sort to throw an exception, but it seems to complete happily. (If you try it with a vector instead of a list, it will error).
Anyway, the typical way to do this would be to convert your Clojure data structure to a mutable Java type first, then convert it back. In this case, perhaps (let [l (ArrayList. '(1 9 6 3 8 9))] (Collections/sort l) (seq l)) The nice thing about this is that there is only one real conversion -- the creation of the ArrayList. Calling "seq" on the result just creates a view on the ArrayList, which is now effectively immutable since after you exit the "let" nobody has write access to it. -Jason On Feb 20, 10:59 am, Steffen Glückselig <goo...@gungfu.de> wrote: > I was trying to use Clojure to verify the behavior some method in > Java. > > Namely I wanted to quickly check whether Collections.sort does the > sorting I need. > > So I came up with: > > (let [list '("1" "KB" "K6" "2" "EÜ" "EZ" "ES")] > (do > (java.util.Collections/sort list) > list)) > > But since Collections/sort mutates the list in place I cannot get a > result. > > Is there a way in Clojure to get at the result of operations like > these? > > Steffen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---