Operator precedence: Difference between revisions

m
no edit summary
m (added a solution for Factor)
mNo edit summary
Line 1,188:
# Parentheses alter the order of evaluation in the usual way.
# Control structures such as ''if ... then ... else ... end'' and ''reduce ... as VAR (...; ...)'' determine the boundaries of subexpressions.
 
=={{header|Julia}}==
<pre>
Julia Operators in Order of Preference
--------------------------------------------
Syntax . followed by ::
Exponentiation ^
Fractions //
Multiplication * / % & \
Bitshifts << >> >>>
Addition + - | ⊻
Syntax : .. followed by |>
Comparisons > < >= <= == === != !== <:
Control flow && followed by || followed by ?
Assignments = += -= *= /= //= \= ^= ÷= %= |= &= ⊻= <<= >>= >>>=
 
Operator precedence can be checked within Julia with the Base.operator_precedence function:
 
julia> Base.operator_precedence(:>=), Base.operator_precedence(:&&), Base.operator_precedence(:(=))
(6, 4, 1)
 
Julia Associativity of Operators
---------------------------------------------
Assignment (=, etc.), conditional (a ? b : c), -> arrows, lazy OR/AND (&& ||),
power operators, and unary operators are right associative. All others are
left associative.
</pre>
 
=={{header|Kotlin}}==
4,111

edits