Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1992

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

Search the Archive

Re: Pattern matching question

  • To: mathgroup at
  • Subject: Re: Pattern matching question
  • From: Silvio Levy <levy at>
  • Date: Thu, 30 Jan 92 09:39:29 PST

Dan Dill notices that NonCommutativeMultiply[a_, b__, c_] := ...
causes NonCommutativeMultiply[x,y,z,t] to match a->x, b->y, c->z**t.
This is because NCM has the flat attribute, so Mathematica feels free
to try to group the arguments any old way in order to obtain a match.
So the match above is legal, and happens to be the first one encountered.
Of course the match a->x, b->(y,z), c->t (the one he wants) would also
be legal.

To avoid the wrong match, say ClearAttributes[NCM,Flat].


  • Prev by Date: response to query in comp.lang.functional
  • Next by Date: Switch and List
  • Previous by thread: Re: Pattern matching question
  • Next by thread: a summary of "Switch and List" (or anything you can do one way with M, you can do 50 other ways)