Skip to content

Instantly share code, notes, and snippets.

@maxcountryman
Created December 24, 2013 15:16
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 maxcountryman/8ee60dbd251730cd1076 to your computer and use it in GitHub Desktop.
Save maxcountryman/8ee60dbd251730cd1076 to your computer and use it in GitHub Desktop.
(def map-of-maps {:foo {:bar 1 :baz 4 :qux 2}})
(reduce (fn [maps k]
(let [m (get maps k)
total (->> m vals (apply +))]
(reduce (fn [maps k*]
(update-in maps [k k*] (fn [n] (/ n total))))
maps (keys (get maps k)))))
map-of-maps (keys map-of-maps))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment