Operator
An Operator is a symbolic representation of a function to be applied on operands. This application is called an operation. Operands can be data items or literals.
In expressions with multiple operators, the precedence of the evaluation is based on the precedence order and the associativity within this order. Operators with lower orders are evaluated first.
Examples:
-3^2
is evaluated as(-3)^2
orpow(neg(3), 2)
due to the higher precedence order of the unary sub operator.a / b * c
is evaluated as(a / b) * c
ormul(div(a,b), c)
due to the equal order and left to right associativity of the multiply and divide operator.a?b:c?d:e
is evaluated asa?b:(c?d:e)
due to the right to left associativity of the immediate if operators.a || b && c
is evaluated asa || (b && c)
oror(a, and(b, c))
due to the higher precedence order of the and operator.
Use brackets to overrule the precedence rules.
Operator | Name | Order Precedence | Associativity | Description | Equivalent Function |
---|---|---|---|---|---|
+ (unary) | plus | 0 | right to left | +a means a | |
- (unary) | minus | 0 | right to left | -a means -a | sub |
# | nrofrows | 0 | - | #u means number of rows of unit u | nrofrows |
^ | power | 1 | left to right | a ^ b means a to the b-th power | pow |
! | subitem | 1 | left to right | a!b means subitem(a, b) | subitem |
. | parent item | 1 | left to right | id(.) means id(parent item) | |
[..] or -> | array access | 1 | left to right | a[b] means lookup(b, a) if b is a data item | lookup |
[..] | value | 1 | left to right | a[b] means value(a,b) if b is a unit | value |
* | multiply | 2 | left to right | a * b means a multiplied with b | mul |
/ | divide | 2 | left to right | a / b means a divided by b (spaces are necessary) | div |
% | modulo | 2 | left to right | a % b means a modulo b | mod |
+(binary) | plus | 3 | left to right | a + b means a plus b | add |
- (binary) | minus | 3 | left to right | a - b means a minus b | sub |
== | equal to | 4 | left to right | a == b means a equals b | eq |
!= | not equal to | 4 | left to right | a b means a not equals b | not |
< | less than | 4 | left to right | a < b means a less than b | lt |
<= | less than orequal to | 4 | left to right | a <= b means a less than or equal to b | le |
> | greater than | 4 | left to right | a > b means a greater than b | gt |
>= | greater than orequal to | 4 | left to right | a >= b means a greater than or equal to b | ge |
! (unary) | not | 5 | right to left | !a means not a | not |
&& | and | 6 | left to right | a && b means a and b | and |
|| | or | 7 | left to right | a || b means a or b | or |
? : | then else (in an iif expression) | 8 | right to left | cond-expr? then-expr: else-expr | iif |
Table of contents
- Arithmetic functions
- Ordering functions
- Aggregation functions
- Conversion functions
- Classify functions
- Transcendental functions
- Predicates functions
- Logical functions
- Relational functions
- Selection functions
- Rescale functions
- Constant functions
- Trigonometric functions
- Geometric functions
- Network functions
- Grid functions
- String functions
- File, Folder and Read functions
- Unit functions
- Matrix functions
- Sequence functions
- MetaScript functions
- Allocation functions
- Miscellaneous functions
- Gui scripting
- Full test
- Projects