Re: RE: Prefix notation
- To: mathgroup at smc.vnet.net
- Subject: [mg40734] Re: [mg40574] RE: [mg40530] Prefix notation
- From: Murray Eisenberg <murraye at attbi.com>
- Date: Tue, 15 Apr 2003 03:59:50 -0400 (EDT)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- References: <200304100741.DAA24268@smc.vnet.net>
- Reply-to: murray at math.umass.edu
- Sender: owner-wri-mathgroup at wolfram.com
Perhaps an even nicer thing to do for such examples -- although it takes a bit of effort to set up -- is to make use of the Notation package so as to employ the traditional mathematical symbol for composition (the little circle). David Park wrote: > Bobby, > > Another nice use for the prefix notation, @, is in writing compositions. It > even looks a little like the composition symbol. > > Here is an example. Suppose we define translations T[v] and rotations > R[angle, center] in the complex plane. > > T[v_][z_] := z + v > R[theta_, a_][z_] := E^(I*theta)*(z - a) + a > > Then to perform a rotation of Pi/4 about 1, followed by a translation of 1, > followed by a rotation of Pi/4 about 0 we write the composition... > > R[Pi/4, 0]@T[1 + I]@R[Pi/4, 1]@z > > E^((I*Pi)/4)*(2 + I + E^((I*Pi)/4)*(-1 + z)) > > David Park > djmp at earthlink.net > http://home.earthlink.net/~djmp/ > > > From: Dr Bob [mailto:majort at cox-internet.com] To: mathgroup at smc.vnet.net > To: mathgroup at smc.vnet.net > > > >>>You make judicious use of what I guess is "infix" notation. >>>Maybe you're minimizing the number of keystrokes one uses. > > > It's actually called prefix notation. I just discovered functions called > Infix, Prefix, and Postfix whose help entries make this clear. > > I like "@" when there's only one argument because, when I see "[", it's > often hard to tell where the matching "]" is, and vice-versa. If I avoid > some brackets by using "@" or "//", that makes it easier to visually match > the remaining brackets, and "@" does save a keystroke, after all. I > generally don't like "//", but it's handy for applying a function of one > argument to a long and complicated mess. > > Sometimes, if the argument needs parentheses, I use f[arg] instead of > f@(arg). > > I tend to use [] if there may be other arguments added later, even though > there's only one argument at the moment. > > Evaluate the following: > > parabola[zero_] := (# - zero)^2 & > parabola@3 > parabola[3][x] > parabola[3]@x > parabola@3@x > (parabola@3)@x > x // parabola@3 > (3 // parabola)@x > 3 // parabola // x > > -- and you'll see that evaluation order might not be what we want or expect > sometimes. > > In this example, I think "parabola[3]@x" might be easiest to read and > write. > > I often use my patented (not really) "multi-click" method to decide what > the evaluation order will be. In x // parabola@3, for instance, click > three or four times in "parabola" and you'll see the selection expand > (under Windows, anyway) in a way that corresponds to evaluation order. > > The "multi-click" method works for finding matching brackets too, if you > already have them where they belong. Prefix notation helps me get them > right, by eliminating some. > > Bobby > > On Tue, 8 Apr 2003 15:58:29 -0400 (EDT), Stewart Mandell > <stewart at rentec.com> wrote: > > >>thanks for pointing out ComplexExpand to me. >> >>You answer lots of queries on the Mathematica NewsGroup. >>You make judicious use of what I guess is "infix" notation. >>Maybe you're minimizing the number of keystrokes onw uses. >>I have to get use to this. >> >>regards, Stewart >> > > > > > -- > majort at cox-internet.com > Bobby R. Treat > > > > -- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street Amherst, MA 01375
- References:
- RE: Prefix notation
- From: "David Park" <djmp@earthlink.net>
- RE: Prefix notation