Nathan Hawkins wrote:
> Possibly I'm going about this wrong. I'm trying to understand how
> best to construct maps from sequences, by applying a function which
> returns a key / value pair.
[...]
> Am I overlooking some already existing function hidden away someplace
> that does this?
Here's a more succinct way:
user> (let [test-str "foo=1;bar=2;baz=3"]
(reduce conj {}
(map #(apply hash-map (seq (.split % "=")))
(.split test-str ";"))))
{"baz" "3", "bar" "2", "foo" "1"}
-Drew
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---