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

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -