Re: Matching with a "Flat" function
- To: mathgroup at smc.vnet.net
- Subject: [mg70892] Re: Matching with a "Flat" function
- From: dh <dh at metrohm.ch>
- Date: Wed, 1 Nov 2006 03:54:58 -0500 (EST)
- References: <ei4knq$da9$1@smc.vnet.net>
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 >