0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-07 15:39:42 -05:00

Optimize d/mapm helper using reduce-kv

This commit is contained in:
Andrey Antukh 2024-01-31 12:56:17 +01:00
parent 893a8992c3
commit 733825edfa

View file

@ -316,9 +316,12 @@
(defn mapm
"Map over the values of a map"
([mfn]
(map (fn [[key val]] [key (mfn key val)])))
(map (fn [[key val]] (vec2 key (mfn key val)))))
([mfn coll]
(into {} (mapm mfn) coll)))
(reduce-kv (fn [coll k v]
(assoc coll k (mfn k v)))
coll
coll)))
(defn removev
"Returns a vector of the items in coll for which (fn item) returns logical false"