I would like to define a function using variables outside of the function.
For example,
g = x + y;
f[x_, y_] := g;
f[1, 2]
then, I hope to get 3 as the answer. In above case, I get
x + y
as the answer.
I would like to define a function using variables outside of the function.
For example,
g = x + y;
f[x_, y_] := g;
f[1, 2]
then, I hope to get 3 as the answer. In above case, I get
x + y
as the answer.
gand have it affectfyou will need that. Ifgis defined beforefonly thenSet(shorthand=) is sufficient. Would you please clarify your intent? – Mr.Wizard Jun 28 '17 at 14:32