Re: rule scoping: bug or feature?
- To: mathgroup at smc.vnet.net
- Subject: [mg37563] Re: rule scoping: bug or feature?
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Tue, 5 Nov 2002 05:00:03 -0500 (EST)
- Organization: Universitaet Leipzig
- References: <aq02c3$3r6$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi, what may RuleDelayed[] do ?? rep = {f[x1_, x2_] :> x2}; Table[{x1, f[x2, x1] /. rep}, {x2, 1, 2}, {x1, 1, 2}] Regards Jens Achim Rosch wrote: > > Is the following a bug or a feature? > > I had expected that > > In[1]:= rep={f[x1_,x2_]->x2}; > > defines a replacement rule, where f is replaced by its second argument. > However, > > In[2]:= Table[ {x1 ,f[x2,x1] /.rep} , {x2, 1,2},{x1, 1,2}] > > gives > > Out[2]= {{{1, 1}, {2, 1}}, {{1, 2}, {2, 2}}} > > instead of {{{1,1},{2,2}},{{1,1},{2,2}}} obviously because the value for > x2 in the rule "rep" is not determined from the pattern at the LHS but > from the summation argument. > I assumed, that definitions involving patterns are always local... > > Any thoughts? Thanks for your help > > Achim > > P.S. One solution for the problem is to use :> innstead of ->