The Order of Precedence of Programming Language Operators
Operator Precedence Examples
The order of precedence of all Maple programming language operators is as follows, from highest to lowest binding strengths:
(on the right)
(on the left)
postfix ++ and --
prefix ++ and --
&-operators (except &*)
., *, &*, /, @, intersect
+, -, union, minus
<, <=, >, >=, =, <>, in
:=, +=, -=, *=, .=, /=, mod=, ^=, ,=, ||=, and=, or=, xor=, implies=, union=, intersect=, minus=
Note that ^ and @@ are defined to be non-associative and therefore a^b^c is invalid in Maple. (Parentheses must be used.)
Note that the precedence of mod is different on the right than on the left. (See examples.)
The evaluation of expressions involving the logical operators proceeds in an intelligent manner which exploits more than the simple associativity and precedence of these operators. Namely, the left operand of the operators and, or, xor, and implies is always evaluated first and the evaluation of the right operand is avoided if the truth value of the expression can be deduced from the value of the left operand alone.
The module member selection operator :− has special rules for simplification and evaluation. It is simplified immediately and automatically to the local instance of the module member name that it denotes. It is not possible to manipulate an :− expression as a compound data structure. The expression appearing to the left of the :− operator must evaluate to a module (it is an error, otherwise), and the symbol appearing to the right of the :− operator must be the name of an exported member of that module.
The precedence of elementwise operators matches that of the operator being applied element-wise.
Because the ^ operator is non-associative, a^b^c returns an error.
Error, ambiguous use of `^`, please use parentheses
However, both (a^b)^c and a^(b^c) are valid.
Because a procedure cannot be a parameter, (a -> b) -> c returns an error. However, a -> b -> c is valid syntax and means a -> (b -> c).
a -> b -> c;
a -> (b -> c);
(a -> b) -> c;
Error, invalid parameter; functional operators require their parameters to be of type symbol or (symbol::type)
On the right side, the precedence of the mod operator is higher than the precedence of the + operator.
a + b mod c + d;
Neutral operators beginning with a single & are left-associative, while those beginning with && are right associative.
a &+ b &+ c;
a &&+ b &&+ c;
Download Help Document
What kind of issue would you like to report? (Optional)