Created
February 6, 2013 20:05
-
-
Save puredanger/4725352 to your computer and use it in GitHub Desktop.
mapmap
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
(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