function | since v1.11.50 | Edit |
(update-vals m f)
m f => {k (f v) ...} Given a map m and a function f of 1-argument, returns a new map where the keys of m are mapped to result of applying f to the corresponding values of m.
(defn update-vals
{:added "1.11"}
[m f]
(with-meta
(persistent!
(reduce-kv (fn [acc k v] (assoc! acc k (f v)))
(if (implements? IEditableCollection m)
(transient m)
(transient {}))
m))
(meta m)))