Order of evaluation of variable

I'd like to control the order of evaluation in a multi-variable function. Example: Suppose I have the function:

B[x_, y_] := x + y/x;


If I try to evaluate B[0,0] I get Indeterminate although if I plug in the value of y first and then x I should get 0. Using an intermediate function is not possible in my case.

Is there any way to tell mathematica to plug in the value of y first, evaluate the function, then plug the value of x ?

• To do what you literally asked: B[x_, y_] := Module[{xx, yy}, xx + yy/xx /. yy -> y /. xx -> x] – Bob Hanlon Nov 5 at 0:07

1 Answer

Maybe easiest to give a definition for your special case, in addition to your general definition.

B[x_, y_] := x + y/x
B[0, 0] := 0