I'm trying to learn the functional style which seems to prevail in Mathematica. I'm having trouble accomplishing the following:
Let's say I have multiple lists of arbitrary data (using two lists here to keep it simple):
a = {1,2,3,4,5,6}
b = {1,1,2,2,3,3}
I also have multiple arbitrary functions (again using two to keep it simple) which all take the same inputs in the same order, but use them to generate different outputs:
f = Function[{u,v},{{u^2,u*v},{-u*v,v^2}}]
g = Function[{u,v},{{u^2,1},{-1,v^2}}]
I understand how to build lists of results, threading over lists a,b, with MapThread:
fOut = MapThread[f,{a,b}]
gOut = MapThread[g,{a,b}]
However, because in reality there are dozens of functions (f,g,etc.) and dozens of lists of data (a,b,etc.), I end up with dozens of MapThread commands, each with the same long list of arguments, creating a wall of text that is far from elegant-looking. So I tried to merge it into a single MapThread command, which didn't work:
{fOut,gOut} = MapThread[{f,g},{a,b}]
Is there a way to MapThread many functions onto many lists of data (assuming each function expects the data in the same order)? If possible, I would like to avoid creating new variables because the functions are intended to be compiled, and I think it would create redundant data.
(# @@@ Transpose@{a, b}) & /@ {f, g}
? Or even:SetAttributes[{f, g}, Listable]; (# @@ {a, b}) & /@ {f, g}
. $\endgroup$Outer[#1 @@ #2 &, {f, g}, Transpose[{a, b}], 1]
$\endgroup$