Re: Flat riddle
- To: mathgroup@smc.vnet.net
- Subject: [mg11575] Re: Flat riddle
- From: Allan Hayes <hay@haystack.demon.co.uk>
- Date: Tue, 17 Mar 1998 10:42:57 -0500
- References: <6ec53m$4h0@smc.vnet.net>
Here is a little more on the peculiarities of Flat with some comments In[1]:= ClearAll["`*"] In[1]:= f[1,x_]=x; (*Rule1*) In[2]:= Attributes[f] ={ Flat}; In[3]:= f[2,x_] = x; (*Rule2: f in stored rule flagged with Flat?*) In[4]:= {f[1,3,4], f[2,3,4]} (*only Rule2 uses Flat*) Out[4]= {f[1,3,4],f[3,4]} In[5]:= Attributes[f] ={}; In[6]:= f[2,3,4] (*Rule2 still used Flat - supporting view that it is internally attached and not got from list Attributes[f]*) Out[6]= f[3,4] In[7]:= f[2,x_] = x; (*try to Rule2 replace with same form but without Flat attached to f*) In[8]:= f[2,3,4] (*replacement does not succeed*) Out[8]= f[3,4] In[9]:= (*try to get rid of Rule2 using UnSet*) f[2,x_]=. In[10]:= ?f (* Rule2 still there*) "Global`f" f[1, x_] = x f[2, x_] = x In[11]:= f[2,3,4] Out[11]= f[3,4] In[12]:= (*use UnSet again*) f[2,x_]=. In[13]:= ?f (*second time round we do remove Rule2*) "Global`f" f[1, x_] = x In[14]:= f[2,3,4] Out[14]= f[2,3,4] -- 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