Skip to content

Instantly share code, notes, and snippets.

@puredanger
Created February 25, 2011 02:30
Show Gist options
  • Save puredanger/843292 to your computer and use it in GitHub Desktop.
Save puredanger/843292 to your computer and use it in GitHub Desktop.
Map creators
(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