Skip to content

Instantly share code, notes, and snippets.

@amitrathore
Forked from puredanger/gist:295099
Created February 5, 2010 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amitrathore/295293 to your computer and use it in GitHub Desktop.
Save amitrathore/295293 to your computer and use it in GitHub Desktop.
; What function can I put as FOO here to yield true
; Tried: hash-set, conj, concat
(defn kv [bag [k v]]
(update-in bag [k] conj v))
(defn mergeMatches [propertyMapList]
"Take a list of maps and merges them combining values into a set"
(reduce #(reduce kv %1 %2) {} in))
(def in
(list
{:a 1}
{:a 2}
{:a 3}
{:b 4}
{:b 5}
{:b 6} ))
;; at the REPL
;user> (mergeMatches in)
;returns this map {:b (6 5 4), :a (3 2 1)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment