Add [fmap] for mapping over map

This commit is contained in:
Felisp 2024-01-08 03:23:03 +01:00
parent 8a627ce256
commit 618304f5eb

View file

@ -68,3 +68,11 @@
(map? default-val)) ; If only one is, we don't care cus then it's just assigment (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 (map-apply-defaults conf-val default-val)}
{k (nil?-else 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)])))