Re: Previous variable affects "/."
- To: mathgroup@smc.vnet.net
- Subject: [mg11261] Re: Previous variable affects "/."
- From: Allan Hayes <hay@haystack.demon.co.uk>
- Date: Wed, 4 Mar 1998 01:39:19 -0500
- References: <6dg8bd$2tr@smc.vnet.net>
Vilis Nams wrote: > > I am using "/." to change expressions, as follows: > > In[1]:= = {{1, 2}, {3, 4}, {5, 6}, {7, 8}}; In[2]:= a /. {x_, > y_} -> {x} > Out[2]:={1}, {3}, {5}, {7}} > The results are expected. > > But, if I now define x to be something already, e.g. In[3]:= = 7; > > Then, when I do the Replace, Mathematica uses my previously-defined x, as follows: > > In[4]:= /. {x_, y_} -> {x} > Out[4]:={7}, {7}, {7}, {7}} Vilis Usse :> instead of -> In[1]:= x = 7; {{1, 2}, {3, 4}, {5, 6}, {7, 8}}; /. {x_, y_} :> {x} Out[1]= {{1},{3},{5},{7}} -- Allan Hayes Mathematica Training and Consulting Leicester, UK hay@haystack.demon.co.uk http://www.haystack.demon.co.uk voice: +44 (0)116 271 4198 fax: +44 (0)116 271 8642