Re: Logical inconsistency
- To: mathgroup at christensen.cybernetics.net
- Subject: [mg1246] Re: Logical inconsistency
- From: beretta at ATHENA.MIT.EDU (Robert K Beretta)
- Date: Fri, 26 May 1995 06:30:18 -0400
- Organization: Massachusetts Institute of Technology
In article <3q14ct$725 at news0.cybernetics.net> jorma.virtamo at vtt.fi (Jorma Virtamo) writes in part: > >The other day I tried to construct a rule that applies >to patterns of type > > test = h[a] + h[1] + h[anything]; > >i.e. a sum of functions with head h. The most natural thing >to do is to define the general pattern by > > patt = Plus[__h]; > >However, when you check for the match, you find to your surprise: > >In[3]:= > MatchQ[test,patt] >Out[3]= > False > Although there are several work-arounds, as you have shown, the _Literal_ head is specifically intended to deal with this issue. For example: In[1]:= test = h[a] + h[1] + h[anything]; In[2]:= patt = Literal[ Plus[__h] ] Out[2]= Literal[Plus[__h]] In[3]:= MatchQ[test,patt] Out[3]= True Hope this helps. Bob Beretta beretta at mit.edu