Skip to content

Instantly share code, notes, and snippets.

@loganlinn
Created February 7, 2013 00:38
Show Gist options
  • Save loganlinn/4727319 to your computer and use it in GitHub Desktop.
Save loganlinn/4727319 to your computer and use it in GitHub Desktop.
(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