Re: ReplaceAll strange behaviour
- To: mathgroup at smc.vnet.net
- Subject: [mg9373] Re: [mg9312] ReplaceAll strange behaviour
- From: Allan Hayes <hay at haystack.demon.co.uk>
- Date: Sat, 1 Nov 1997 03:33:58 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Gadi Oron <oron at manet.pmmh.espci.fr> [mg9312] ReplaceAll strange behaviour > Can anybody enlighten me with the following strange result? > > In:= {{1,2},{2,3}} /. {x_ /; Head[x]!=List,y_}:> Circle[{x,y},1] > Out:= > {{1,2},{2,3}} Gadi: You need Head[x]=!=List in place of Head[x]!=List. In[1]:= {{1,2},{2,3}} /. {x_ /; Head[x]=!=List,y_}:> Circle[{x,y},1] Out[1]= {Circle[{1,2},1],Circle[{2,3},1]} Explanation: In[2]:= Head[1] !=List Out[2]= Integer != List In[3]:= Head[1] =!=List Out[3]= True Probably quicker is the following variant: In[4]:= {{Pi,2},{2,3}} /. {x_?NumericQ,y_}:> Circle[{x,y},1] Out[4]= {Circle[{Pi,2},1],Circle[{2,3},1]} Allan Hayes hay at haystack.demon.co.uk http://www.haystack.demon.co.uk/ voice:+44 (0)116 2714198 fax: +44 (0)116 2718642 12, Copse Close Oadby Leicester, UK