Suppose I have a list of functions:

functions = {f, g, h, ...}

And all of those functions are in form of f[x_ , y_]. For example:

f[x_, y_] = x + y;
g[x_, y_] = x^3 + y^2 + 2x;
(*Pass x and y for eval?*)
functions[2, 3] (*- Does not work :( *)
Print[MatrixForm[functions[2,3]]] (*The expected result would be a vector
of calculated function values...*)

Is there any easy way to pass arguments to the list of functions, so that they all will be evaluated?

f[x_, y_] = x + y;
g[x_, y_] = x^3 + y^2 + 2 x;
functions = {f, g};

Using Map

#[x, y] & /@ functions

(* {x + y, 2 x + x^3 + y^2} *)

Using Through

Through[functions[x, y]] *)

(* {x + y, 2 x + x^3 + y^2}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.