Skip to content

Instantly share code, notes, and snippets.

@puredanger
Created February 4, 2010 20:59
Show Gist options
  • Save puredanger/295099 to your computer and use it in GitHub Desktop.
Save puredanger/295099 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 mergeMatches [propertyMapList]
"Take a list of maps and merges them combining values into a set"
(reduce #(merge-with FOO %1 %2) {} propertyMapList))
(def in
(list
{:a 1}
{:a 2}
{:a 3}
{:b 4}
{:b 5}
{:b 6} ))
(def out
{ :a #{ 1 2 3}
:b #{ 4 5 6} })
; this should return true
(= (mergeMatches in) out)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment