Updated because I misinterpreted the question.
Here's another solution:
(apply assoc v (mapcat
that is, create an argument list of index / new-value pairs for assoc . I think mange solutions are probably better, but.
The original, wrong decision
Do not forget that the vector v itself is a function of its indices. So:
(map myfn (map v idx))
or
(->> idx (map v) (map myfn))
or
(map (comp myfn v) idx)
I'm sure there is also a very smart answer involving juxt :)
Dave ray
source share