MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Flat riddle



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




  • Prev by Date: editing problems
  • Next by Date: Copying from Mathematica
  • Prev by thread: Re: Flat riddle
  • Next by thread: Integrate E^(I x) Bug?