|
[Date Index]
[Thread Index]
[Author Index]
Bug in Pattern Matching ??!?
- To: mathgroup at smc.vnet.net
- Subject: [mg29767] Bug in Pattern Matching ??!?
- From: "Drago Ganic" <drago.ganic at in2.hr>
- Date: Sun, 8 Jul 2001 01:00:11 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
some time ago ther was a post which received no answer from the group (as far as I know).
The problem was in this behaviour of Mathematica:
In[1]:= MatchQ[f[1, 2], f[x_Integer, y___]]
Out[1]= True
In[2]:= SetAttributes[f, Flat]
In[3]:= MatchQ[f[1, 2], f[x_Integer, y___]]
Out[4]= False
I don't see why the Flat attributes should change the behavoiur of Mathematica in this case. Here is the same thing without MatchQ:
In[4]:=h[1, 2] /. h[x_Integer, y___] :> "OK"
Out[4]= "OK"
In[5]:= SetAttributes[h, Flat]
In[6]:= h[1, 2] /. h[x_Integer, y___] :> "OK"
Out[6]=h[1, 2]
The problem is in the *head* restriction (Integer). Without it, everything is fine:
In[7]:= h[1, 2] /. h[x_, y___] :> "OK"
Out[7]= "OK"
To me this is a Bug, ... , or is it a feature :-).
Greetings from Croatia,
Drago Ganic
Prev by Date:
icon to Evaluate Notebook?
Next by Date:
TeXSave, TeXForm, etc.
Previous by thread:
Re: Re: icon to Evaluate Notebook?
Next by thread:
TeXSave, TeXForm, etc.
|