1
$\begingroup$

How can I build a program in Mathematica in which I pass a multivariate function f[x,y] to a Module, so that the I am able to use the function fall f[x,y] within the Module. I keep running into errors, and I am not sure how to fix the problem. Thanks.

$\endgroup$

closed as off-topic by Hurkyl, Xander Henderson, Wouter, TheSimpliFire, steven gregory Mar 10 '18 at 7:30

  • This question does not appear to be about math within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ There is a specific SE site for Mathematica questions, you will probably get a quicker and better answer there. $\endgroup$ – David Jan 9 '18 at 4:12
  • 3
    $\begingroup$ I'm voting to close this question as off-topic because this topic belongs on a different stackexchange site. $\endgroup$ – Hurkyl Mar 10 '18 at 1:10
  • $\begingroup$ Please go to Mathematica site with listing of the code you have so far. I do that often and get excellent support. $\endgroup$ – Narasimham Mar 10 '18 at 6:25
0
$\begingroup$

That is straightforward: You just pass the symbol

program[myFunc_] := Module[{x = 1, y = 2},
  myFunc[x, y]
]

program[Plus]

(* 3 *)

It doesn't matter if it is a built-in function or a function you have defined yourself. To be exact, the symbol you are passing doesn't even need to be defined. If Mathematica can not evaluate it, then the expression is just returned as you would expect it:

program[unknownFunc]

(* unknownFunc[1, 2] *)
$\endgroup$

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