Skip to content

Instantly share code, notes, and snippets.

@orb
Created April 26, 2014 21:39
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 orb/11331850 to your computer and use it in GitHub Desktop.
Save orb/11331850 to your computer and use it in GitHub Desktop.
(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