On May 4, 5:07 pm, Christophe Grand <christo...@cgrand.net> wrote:
> Michel S. a écrit :
>
> >> (apply conj {} (map split-kv (split-pairs test-str)))
>
> > The last can be simplified by using into:
> > (into {} (map split-kv (split-pairs test-str)))
>
> It should be noted that into (and conj) is somewhat tricky with maps:
> user=> (into {} '({1 2} {3 4}))
> {3 4, 1 2}
> user=> (into {} '([1 2] [3 4]))
> {3 4, 1 2}
> user=> (into {} '((1 2) (3 4)))
> java.lang.ClassCastException: java.lang.Integer cannot be cast to
> java.util.Map$Entry (NO_SOURCE_FILE:0)
>
> It bit me before.
>
Yes, me too. The design is a bit unfortunate, as I cannot convert a
Scheme-style association list to a map easily:

user=> (into {} '((cars bmw chevrolet ford peugeot)
             (genres adventure horror mystery)))

java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to
java.util.Map$Entry (NO_SOURCE_FILE:0)

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