Pattern matching question
- To: mathgroup at yoda.physics.unc.edu
- Subject: Pattern matching question
- From: dan at chem.bu.edu (Dan Dill)
- Date: Wed, 29 Jan 92 16:39:45 -0500
Can someone help me understand the following pattern matching behavior?
Mathematica 2.0 for Sun-3 68881
Copyright 1988-91 Wolfram Research, Inc.
-- ~/math/Packages added to $Path --
-- ~/course/eg added to $Path --
-- X11 windows graphics initialized --
In[1]:= Unprotect[NonCommutativeMultiply]; \
Clear[NonCommutativeMultiply]; \
NonCommutativeMultiply[a_, b__, c_] := NonCommutativeMultiply[b, a[c]]; \
a ** b ** c ** d
Out[1]= b ** a[c ** d]
I expected (wanted) instead
c ** b[a[d]],
via
a ** b ** c ** d --> b ** c ** a[d] --> c ** b[a[d]],
by analogy with
In[2]:= op[a_, b__, c_] := op[b, a[c]]; \
op[a, b, c, d]
Out[2]= op[c, b[a[d]]]
Thanks
Dan
dan at chem.bu.edu