clojure - Update and replace map value -
i'm sure it's right here in front of me, i'm missing it. examine following:
(assoc :position entity (add (:position entity) (:velocity entity)))
what want (with fake function called altermap):
(altermap :position entity #((add % (:velocity entity)))
what suggested method? there built-in function #2?
update-in
altermap
function, except takes vector of keys instead of single key. so:
(update-in entity [:position] #(add % (:velocity entity)))
to best of knowledge there no single-key variant of update-in
, having put brackets around key shouldn't cumbersome.
Comments
Post a Comment