Consider a set of (here) 3 series
r`data = Thread[{Range@4, # Range@4}] & /@ (10 Range@3);
(*{
{{1, 10}, {2, 20}, {3, 30}, {4, 40}},
{{1, 20}, {2, 40}, {3, 60}, {4, 80}},
{{1, 30}, {2, 60}, {3, 90}, {4, 120}}
}*)
The intent is to divide the second coordinate of each point in each series by some divisor divs[[i]]
r`divs = 10 Range@3;
(*{10, 20, 30}*)
I am currently achieving this as follows
r`f[x_] := #/x &
MapThread[MapAt[r`f@#2, #1, {All, 2}] &, {r`data, r`divs}]
(*{
{{1, 1}, {2, 2}, {3, 3}, {4, 4}},
{{1, 1}, {2, 2}, {3, 3}, {4, 4}},
{{1, 1}, {2, 2}, {3, 3}, {4, 4}}
}*)
How to eliminate r`f
in favour of directly nesting the division lambda #/x &
, present in the MapAt
, inside the MapThread
?
In other words how to correctly write something of the kind
MapThread[MapAt[#/#2 &, #1, {All, 2}] &, {r`data, r`divs}]
^
|
|
should refer to second coord of point
and not r`data[[i]]
Please note that I did go through similar questions (e.g. MapThread on a nested Map) but couldn't apply their solutions to the present case.
MapThread[#1.DiagonalMatrix[{1, 1/#2}] &, {r`data, r`divs}]
? $\endgroup$