Re: Precedence

*To*: mathgroup at smc.vnet.net*Subject*: [mg60329] Re: Precedence*From*: Paul Abbott <paul at physics.uwa.edu.au>*Date*: Tue, 13 Sep 2005 06:07:09 -0400 (EDT)*Organization*: The University of Western Australia*References*: <dfrgpu$fr6$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

In article <dfrgpu$fr6$1 at smc.vnet.net>, "Xerxes" <Xerxes314 at gmail.com> wrote: > I've been writing a package using Mathematica to do lattice > perturbation theory. As a part of my package, I'd like to > define my own matrix multiplication, which I call dotm. Since > CenterDot looks pretty and has no previous assignment, I've > used it as both the input and output format of dotm. However, > I run into problems when I try to type things like > > Y[x].g A[x].Y[x+a] > > where the . should be imagined to be CenterDot. Because the > precedence of the . is higher than the precedence of the > multiplication, this gives (Y.g)(A.Y) instead of Y.(gA).Y. > > I know I can attach a TagBox to the CenterDot to force it to > have lower precedence, but that ruins the convenience of typing > esc-.-esc to get the dot. Is there some other way to teach > Mathematica to use a lower precedence? You can use <<Utilities`Notation` to define your notation and also to change the precedence (using SyntaxForm). Evaluate FrontEndExecute[ FrontEnd`HelpBrowserLookup["DemosLink", "Notation Package"]] for more information, especially the section on "Complex Patterns and Advanced Features" Cheers, Paul _______________________________________________________________________ Paul Abbott Phone: 61 8 6488 2734 School of Physics, M013 Fax: +61 8 6488 1014 The University of Western Australia (CRICOS Provider No 00126G) AUSTRALIA http://physics.uwa.edu.au/~paul