Created
February 7, 2013 00:38
-
-
Save loganlinn/4727319 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 filter-map | |
"Returns map with items in m for which f returns true. | |
f should take 2 arguments [key value]" | |
[f m] | |
(into {} (for [[k v] m :when (f k v)] [k v]))) | |
(defn map-map | |
"Returns map after applying f to key/values in m. | |
f should take 2 arguments [key value] and return a sequence of 2 items [key' value']" | |
[f m] | |
(into {} (for [[k v] m] (f k v)))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment