(into {} (apply map vector
                '((cars bmw chevrolet ford peugeot)
                  (genres adventure horror mystery))))

{ford mystery, chevrolet horror, bmw adventure, cars genres}


On Mon, May 4, 2009 at 4:03 PM, Michel S. <michel.syl...@gmail.com> wrote:
>
>
>
> 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
> >
>



-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

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