Skip to content

Instantly share code, notes, and snippets.

@puredanger
Created February 6, 2013 20:05
Show Gist options
  • Save puredanger/4725352 to your computer and use it in GitHub Desktop.
Save puredanger/4725352 to your computer and use it in GitHub Desktop.
mapmap
(defn mapmap
"Apply kf and vf to a sequence, s, and produce a map of (kf %) to (vf %)."
([vf s]
(mapmap identity vf s))
([kf vf s]
(zipmap (map kf s)
(map vf s))))
(defn mapmapmap
"Apply kf and vf to the keys and vals of a map and zip the results."
([vf m]
(mapmapmap identity vf m))
([kf vf m]
(mapmap (comp kf key) (comp vf val) m)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment