If you're not worried about order, you could also write:
(reduce (fn [m [k v]] (update-in m [k] conj v)) {} values)
- James
On 6 February 2014 00:40, Paul Mooser <[email protected]> wrote:
> This is very similar to Sean's solution, but all values will be vectors:
>
> (reduce
> (fn [acc [k v]]
> (update-in acc [k]
> #(conj (or %1 []) v))) {}
> [[:a 123] [:b 124] [:a 125] [:c 126] [:b 127] [:a 100]])
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to [email protected]
> Note that posts from new members are moderated - please be patient with
> your first post.
> 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
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.