MathGroup Archive 2006

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

Search the Archive

Re: Matching with a "Flat" function


Hi,
if you double the Blank in your pattern it will match the expression:
MatchQ[f[2], f[__Integer]]
Why this is so, I can not tell, it looks like an argument of a function 
with the attribute "Flat" counts double.
This looks like a bug to me.
Daniel

Szabolcs wrote:
> Could someone explain this behaviour to me? I'd expect f[_Integer] to
> match f[2] even after I set attribute Flat on f.
> 
> Szabolcs
> 
> In[1]:= MatchQ[f[2],f[_]]
> 
> Out[1]= True
> 
> In[2]:= MatchQ[f[2],f[_Integer]]
> 
> Out[2]= True
> 
> In[3]:= SetAttributes[f,Flat]
> 
> In[4]:= MatchQ[f[2],f[_]]
> 
> Out[4]= True
> 
> In[5]:= MatchQ[f[2],f[_Integer]]
> 
> Out[5]= False
> 


  • Prev by Date: Re: surface plot of an image
  • Next by Date: Merging graphic objects, exporting graphics and much more worries...
  • Previous by thread: Re: Matching with a "Flat" function
  • Next by thread: Re: RE: Labelled ticks at the origin