Created
February 27, 2013 20:16
-
-
Save amalloy/5051301 to your computer and use it in GitHub Desktop.
This file contains 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
(let [inputs [{:date1 | |
[{:user "user 1" | |
:metric1 1 | |
:metric2 2} | |
{:user "user 2" | |
:metric1 3 | |
:metric2 4}]} | |
{:date2 | |
[{:user "user 1" | |
:metric1 5 | |
:metric2 6} | |
{:user "user 2" | |
:metric1 7 | |
:metric2 8}]}]] | |
(reduce (fn [m path] | |
(assoc-in m (pop path) (peek path))) | |
{} | |
(for [input inputs, | |
[date objs] input | |
obj objs | |
:let [user (:user obj), obj (dissoc obj :user)] | |
[metric value] obj] | |
[metric date (str "user " user) value]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment