The Clojure collections are immutable, which is their entire reason for
existing.  However, there is nothing stopping you from creating a plain old
Java collection in Clojure.
(let [list (ArrayList. '("Fred" "mary" "sue")]
  (do
    (java.util.Collections/sort list)
    list))

Should work.

On Fri, Feb 20, 2009 at 1:59 PM, 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to