Created
April 26, 2014 21:39
-
-
Save orb/11331850 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
(def matches | |
{:a {:a "foo" :b "bar"} | |
:b {:a "blue" :b {:a "fred" :b "bob"}}}) | |
(defn winner [node] | |
(if (map? node) | |
(:winner node) | |
node)) | |
(defn select-winner [node aorb] | |
(assoc node :winner (winner (aorb node)))) | |
(-> matches | |
(update-in [:b :b] select-winner :a) | |
(update-in [:b] select-winner :b) | |
(update-in [:a] select-winner :a) | |
(select-winner :a)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment