One way:

user> (reduce (fn [s [k v]]
                (merge-with concat s {k [v]}))
              {} [[:a 123]
                  [:b 124]
                  [:a 125]
                  [:c 126]
                  [:b 127]
                  [:a 100]])

=> {:c [126], :b (124 127), :a (123 125 100)}


On Tue, Feb 4, 2014 at 1:06 PM, Thomas <th.vanderv...@gmail.com> wrote:

> Hi all,
>
> I was wondering how I can convert the following data structure to the one
> below:
>
> from:
>
> [[:a 123]
>  [:b 124]
>  [:a 125]
>  [:c 126]
>  [:b 127]
>  [:a 100]]
>
> to
>
> {:a [123 125 100] :b [124 127] :c [126]}
>
> All the names here are arbitrary, but there are potentially a lot more
> keys and certainly a lot more numbers. The order of things is not important.
>
> TIA,
> Thomas
>
> --
> 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
> ---
> 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 clojure+unsubscr...@googlegroups.com.
> 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 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
--- 
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to