rule scoping: bug or feature?
- To: mathgroup at smc.vnet.net
- Subject: [mg37504] rule scoping: bug or feature?
- From: Achim Rosch <trest.trest at gmx.de>
- Date: Sat, 2 Nov 2002 03:30:23 -0500 (EST)
- Organization: University of Karlsruhe, Germany
- Sender: owner-wri-mathgroup at wolfram.com
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 ->