I am looking for an elegant way to Map multiple functions over an array. My problem looks something like this:
Consider a list of functions:
f = {f1,f2,f3,f4} (* example, can be larger *)
And an array:
A = {{a1, b1, c1, d1, e1}, {a2, b2, c2, d2, e2}, {a3, b3, c3, d3, e3}}; (*example, can be larger*)
Q1: I’d like to map the functions in f over the array A so that the final result looks like:
B= {{1 - a1, f1[a1]*b1, f2[a1]*c1, f3[a1]*d1, f4[a1]*e1}, {1 - a2,
f1[a2] b2, f2[a2] c2, f3[a2] d2, f4[a2] e2}, {1 - a3, f1[a3] b3,
f2[a3] c3, f3[a3] d3, f4[a3] e3}}
Q2: How do I map the functions a little differently so that the output looks like:
c= {{a1, f1[a1] b1, f2[b1] c1, f3[c1] d1, f4[d1] e1}, {a2, f1[a2] b2,
f2[b2] c2, f3[c2] d2, f4[d2] e2}, {a3, f1[a3] b3, f2[b3] c3,
f3[c3] d3, f4[d3] e3}} // tf
func[{a_, b_, c_, d_}] := {1 - a, b f1[a], c f2[a], d f3[a], e f4[a]}
and thenfunc/@A
is pretty elegant, I think. $\endgroup$