Created
May 28, 2012 16:19
-
-
Save rrees/2819932 to your computer and use it in GitHub Desktop.
Event reducer example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def example-story-events [ | |
{ | |
:title "Funding cut again" | |
:tags [:science] | |
:author ["Chuck Newton"] | |
} | |
{ | |
:tags [:politics] | |
} | |
{ | |
:title "A difficult tightrope to cross" | |
} | |
]) | |
(defn article-reducer [acc event] | |
(into acc | |
(for [[k, v] event] | |
(if (vector? v) | |
[k (concat (k event) (k acc) )] | |
[k v])))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment