(update m k f)
(update m k f x)
(update m k f x y)
(update m k f x y z)
(update m k f x y z & more)
'Updates' a value in an associative structure, where k is a
key and f is a function that will take the old value
and any supplied args and return the new value, and returns a new
structure. If the key does not exist, nil is passed as the old value.
Source
(defn
update
"'Updates' a value in an associative structure, where k is a\n key and f is a function that will take the old value\n and any supplied args and return the new value, and returns a new\n structure. If the key does not exist, nil is passed as the old value."
([m k f] (assoc m k (f (get m k))))
([m k f x] (assoc m k (f (get m k) x)))
([m k f x y] (assoc m k (f (get m k) x y)))
([m k f x y z] (assoc m k (f (get m k) x y z)))
([m k f x y z & more] (assoc m k (apply f (get m k) x y z more))))