Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1995
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

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

Search the Archive

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


  • 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