I cannot find operator precedence documented anywhere. With the
operators from Fortran (in the old days) this was always clear, i.e
'/' before '-'.
I have been reading some code in the Trott Guidebooks which has
constructions like 'Head @@ face[[i]] / order'. I can guess that Part
has precedence in this expression, but what about Apply vs. Times?
Looking at the OutputForm shows that Apply has precendence. But,...
- Is this documented somewhere?
- Do all Mathematica operators take precedence over arithmetic operators?
TIA.
Regards..
tutorial/InputSyntax
In the section "Operator Input Forms" there you'll find a long table
that lists the operators in order of precedence along with additional
explanation.
--
Murray Eisenberg mur...@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 fax 413 545-1801
Amherst, MA 01003-9305
This is again proof that a hand-made book index can be much more useful
than any kind of full-text search!
I found the relevant sections immediately in the Mathematica 5.2 help.
It took me somewhat more time to look up the same sections in the v6
documentation, even tough I know their title ... :
tutorial/TheSyntaxOfTheMathematicaLanguage
tutorial/InputSyntax (scroll down to Operator Input Forms)
--
Szabolcs
Hello
Enter "tutorial/InputSyntax" in the text field in the Documentation
Center and hit return.
Then scroll down to the section "Operator Input Forms".
There you will find a long table with operators in decreasing
precedence. One column also tells you how these operators are grouped.
Another way to find out about precedence is clicking in the expression
and repeatedly enlarge the selection with Ctrl . (i.e. pres Ctrl and
the point) or clicking the left mouse button repeatedly (fast).
I hope this helps.
Best Regards
Norbert Marxer
About operator precedences, there exists nothing better than the good
old Mathematica Book!
The following section contains a long table listing the operators in
order of decreasing precedence:
"A.2.7 Operator Input Forms"
http://documents.wolfram.com/mathematica/book/section-A.2.7
The following two (short) sections contain additional material,
explanations and useful examples.
"2.1.3 Special Ways to Input Expressions"
http://documents.wolfram.com/mathematica/book/section-2.1.3
"2.9.16 Defining Output Formats"
http://documents.wolfram.com/mathematica/book/section-2.9.16
Regards,
--
Jean-Marc
There is an undocumented function, Precedence, which can be useful:
Precedence /@ {Plus, Minus, Times, Power, Apply, Map}
gives the output:
{310., 480., 400., 590., 620., 620.}
I can't remember where I got this info, but it may have been in a
presentation by Kris Carlson.
Tom Dowling
On 10/31/07, congruenti...@yahoo.com <congruenti...@yahoo.com>
wrote:
>
> Hello Mathematica UG:
>
> I cannot find operator precedence documented anywhere. With the
> operators from Fortran (in the old days) this was always clear, i.e
> '/' before '-'.
>
> I have been reading some code in the Trott Guidebooks which has
> constructions like 'Head @@ face[[i]] / order'. I can guess that Part
> has precedence in this expression, but what about Apply vs. Times?
>
> Looking at the OutputForm shows that Apply has precendence. But,...
>
> - Is this documented somewhere?
> - Do all Mathematica operators take precedence over arithmetic operators?
>
> TIA.
>
> Regards..
>
>
>
in "The Mathematica Book", Fourth Edition, page 1012
Regards
Jens
If you search for Input Syntax in the help viewer, the first hit includes a
table with all of the operators (infix, prefix, and postfix) listed in order of
decreasing precedence (in the "Operator Input Forms" section). I agree that
this should be easier to find.
Sincerely,
John Fultz
jfu...@wolfram.com
User Interface Group
Wolfram Research, Inc.