MathGroup Archive 1995

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

Search the Archive

Re: Logical inconsistency


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


  • Prev by Date: brackets and braces in frontend with german DEC-keyboard
  • Next by Date: Graphic Bugs: Large circle
  • Previous by thread: Logical inconsistency
  • Next by thread: Re: Logical inconsistency