MathGroup Archive 1992

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

Search the Archive

Pattern matching question


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





  • Prev by Date: Experiences with Mma 2.0 on a Mac
  • Next by Date: Re:Wordwrapping in matrices
  • Previous by thread: Re: Experiences with Mma 2.0 on a Mac
  • Next by thread: Re: Pattern matching question