Add [fmap] for mapping over map
This commit is contained in:
parent
8a627ce256
commit
618304f5eb
1 changed files with 8 additions and 0 deletions
|
@ -68,3 +68,11 @@
|
|||
(map? default-val)) ; If only one is, we don't care cus then it's just assigment
|
||||
{k (map-apply-defaults conf-val default-val)}
|
||||
{k (nil?-else conf-val default-val)})))))
|
||||
|
||||
(defn fmap [f m]
|
||||
"Applies function [f] to every key and value in map [m]
|
||||
Function signature should be (f [key value])."
|
||||
(into
|
||||
(empty m)
|
||||
(for [[key val] m]
|
||||
[key (f key val)])))
|
||||
|
|
Loading…
Reference in a new issue