MathGroup Archive 2006

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

Search the Archive

Re: Matching Or expressions

  • To: mathgroup at
  • Subject: [mg72269] Re: Matching Or expressions
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at>
  • Date: Sun, 17 Dec 2006 06:20:27 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <em0ia6$cbr$>

Johan Grönqvist wrote:
> The context of my problem is explained below.
> I wish to distinguish expressions of the form And[p,q] from those of the 
> form Or[p,q], but the only thing I find is
> MatchQ[myExpr, Or[_]]
> and to my surprise I see that MatchQ[And[p,q],Or[_]] is True. Thus I can 
> not use this to match only the Or-expressions.

Above, you are looking for any pattern (the underscore), which will be 
named "Or". What you want to test is the head of the expression as in 
the expression below.

expr = x == 2 && y == 4;
MatchQ[expr, _Or]
MatchQ[expr, _And]





  • Prev by Date: Re: Notebook Typesetting for Printing
  • Next by Date: Re: Complex Numbers to list of points
  • Previous by thread: Re: Matching Or expressions
  • Next by thread: RE: Matching Or expressions