Re: rules->function

*To*: mathgroup at smc.vnet.net*Subject*: [mg7404] Re: [mg7338] rules->function*From*: seanross at worldnet.att.net*Date*: Fri, 30 May 1997 01:20:25 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

Lord of Darkness wrote: > > Hello All, > > If I solve a set of simultaneous equations and get a simple answer like > zrule = z-> x^2 + y^2 > > but I then want to evaluate > fn[x_,y_] := z + some more stuff..... > > I tried saying > > fn[x_,y_] := Replace[z,zrule] + .... > > but it doesn't seem to handle it the way I wanted... > > Is there a correct way of doing this ? > > thanks > > John B No, there is no single correct way to do it. My particular way is like this: f[a_,b_]=Evaluate[z/.zrule]/.{x->a,y->b} The reason your approach did not work is that mathematica has real trouble when function arguments appear on the left hand side of replacement rules. You also used := which waits to execute the instructions until called upon. By that time, x and y are numbers, not generic symbols and that gets you into trouble as well. P.S. Whats with the "Lord of Darkness" handle? Were you Darth Vader in a previous life?