Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1992
*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 1992

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

Search the Archive

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





  • 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