Well there is a bug. One declaration is missing...
Try add your routine:

(defn hash-map2
    ([ keyvals]
     (. clojure.lang.PersistentHashMap (create keyvals))))

Then call

  (hash-map2 (HashMap. { "tom" "boom" } ) )


Wiadomość napisana przez Alex Osborne w dniu 2009-11-09, o godz. 23:55:

>
> Michael Jaaka wrote:
>> How to convert HashMap<String, String> to Clojure map, sorted-map,
>> tree-map
>>
>> How far I'm able only to do it with
>>
>> (let [a (HashMap. { "abc" "def"}) ]
>>   (zipmap (keys a) (vals a)))
>>
>> Note that HashMap. { ... } is here only as example, cause in fact it
>> is a result from Java method call.
>>
>> What with sorted-map, tree-map and any other types (set, arrays,
>> double dimension arrays)?
>> Is there any brief tutorial showing how to convert any Complex Java
>> type to Clojure type
>> I want do that because I want my data structures immutable.
>
> (into {} (HashMap. {:b 2, :a 1}))
> => {:b 2, :a 1}
>
> (into (sorted-map) (HashMap. {:b 2, :a 1}))
> => {:a 1, :b 2}
>
> (into [] (to-array [1 2 3]))
> => [1 2 3]
>
> (into [] (ArrayList [1 2 3]))
> => [1 2 3]
>
> and so on...
>
> >


--~--~---------~--~----~------------~-------~--~----~
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
Note that posts from new members are moderated - please be patient with your 
first post.
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