Built-in operators
This page describes the built-in operators:
The signatures of the operators are given using tool headers, to show the name of the operator, the types of the arguments, and the type of the resulting value. Operators however, can not be used by means of tool invocations. Operators with one argument are put directly before the argument (e.g. not true
, -5
), while operators with two arguments are put between the arguments (e.g. true and false
, 1 + 3
).
not operator
tool bool not(bool arg)
Returns the logical inverse of a boolean value.
Arguments
-
arg
-
The boolean value.
Returns
The logical inverse result.
and operator
tool bool and(bool left, bool right)
tool set T and<T>(set T left, set T right)
Returns the conjunction of two boolean values, or the intersection of two sets. For boolean values, the operator uses short circuit evaluation. That is, the right
argument is only evaluated if necessary, i.e. only if the left
argument evaluates to true
.
Type parameters
-
T
-
The type of the elements of the set.
Arguments
-
left
-
The first boolean value or set.
-
right
-
The second boolean value or set.
Returns
The conjunction or intersection result.
or operator
tool bool or(bool left, bool right)
tool set T or<T>(set T left, set T right)
Returns the disjunction of two boolean values, or the union of two sets. For boolean values, the operator uses short circuit evaluation. That is, the right
argument is only evaluated if necessary, i.e. only if the left
argument evaluates to false
.
Type parameters
-
T
-
The type of the elements of the set.
Arguments
-
left
-
The first boolean value or set.
-
right
-
The second boolean value or set.
Returns
The disjunction or union result.
+ operator (unary)
tool int +(int arg)
tool long +(long arg)
tool double +(double arg)
Returns the unary plus of an integer, long, or double value. This is essentially the identity function.
Arguments
-
arg
-
The integer, long, or double value.
Returns
The integer, long, or double value.
+ operator (binary)
tool int +(int left, int right)
tool long +(long left, long right)
tool double +(double left, double right)
tool string +(string left, string right)
tool list T +<T>(list T left, list T right)
tool map(K:V) +<K, V>(map(K:V) left, map(K:V) right)
Returns the addition of two integer, long, or double numbers, the concatenation of two strings or lists, or the update of a first map with the entries of a second map. For two maps, essentially, the entries of the first map are overwritten by the entries of the second map, while entries for new keys are added.
Type parameters
-
T
-
The type of the elements of the list.
-
K
-
The type of the keys of the map.
-
V
-
The type of the values of the map.
Arguments
-
left
-
The first integer, long, or double number, string, list, or map.
-
right
-
The second integer, long, or double number, string, list, or map.
Returns
The addition, concatenation, or map update result.
Runtime errors
-
If the operation results in overflow (for integer, long, and double numbers only).
- operator (unary)
tool int -(int arg)
tool long -(long arg)
tool double -(double arg)
Returns the negation of an integer, long, or double value.
Arguments
-
arg
-
The integer, long, or double value.
Returns
The negation result.
Runtime errors
-
If the operation results in overflow.
- operator (binary)
tool int -(int left, int right)
tool long -(long left, long right)
tool double -(double left, double right)
tool set T -<T>(set T left, set T right)
tool map(K:V) -<K, V>(map(K:V) left, list K right)
tool map(K:V) -<K, V>(map(K:V) left, set K right)
tool map(K:V) -<K, V, V2>(map(K:V) left, map(K:V2) right)
Returns the subtraction of two integer, long, or double numbers, the set difference of two sets, the map with the keys from the list removed from it, the map with the keys from the set removed from it, or the first map with the keys from the second map removed from it.
Type parameters
-
T
-
The type of the elements of the list.
-
K
-
The type of the keys of the map.
-
V
-
The type of the values of the map.
Arguments
-
left
-
The first integer, long, or double number, the first set, or the (first) map.
-
right
-
The second integer, long, or double number, the (second) set, the list, or the second map.
Returns
The subtraction, set difference, or map removal result.
Runtime errors
-
If the operation results in overflow (for integer, long, and double numbers only).
* operator
tool int *(int left, int right)
tool long *(long left, long right)
tool double *(double left, double right)
Returns the multiplication of two integer, long, or double numbers.
Arguments
-
left
-
The first integer, long, or double number.
-
right
-
The second integer, long, or double number.
Returns
The multiplication result.
Runtime errors
-
If the operation results in overflow.
/ operator
tool double /(double left, double right)
Returns the division of two double numbers.
Arguments
-
left
-
The first double number.
-
right
-
The second double number.
Returns
The division result.
Runtime errors
-
If the operation results in overflow or division by zero.
div operator
tool int div(int left, int right)
tool long div(long left, long right)
Returns the integer division of two integer or long numbers.
Arguments
-
left
-
The first integer or long number.
-
right
-
The second integer or long number.
Returns
The integer division result.
Runtime errors
-
If the operation results in overflow or division by zero.
mod operator
tool int mod(int left, int right)
tool long mod(long left, long right)
Returns the modulus of two integer or long numbers.
Arguments
-
left
-
The first integer or long number.
-
right
-
The second integer or long number.
Returns
The modulus result.
Runtime errors
-
If the operation results in division by zero.
< operator
tool bool <(int left, int right)
tool bool <(long left, long right)
tool bool <(double left, double right)
Returns whether the first integer, long, or double number is less than the second integer, long, or double number.
Arguments
-
left
-
The first integer, long, or double number.
-
right
-
The second integer, long, or double number.
Returns
true
if the first number is less than the second number, false
otherwise.
<= operator
tool bool <=(int left, int right)
tool bool <=(long left, long right)
tool bool <=(double left, double right)
Returns whether the first integer, long, or double number is less than or equal to the second integer, long, or double number.
Arguments
-
left
-
The first integer, long, or double number.
-
right
-
The second integer, long, or double number.
Returns
true
if the first number is less than or equal to the second number, false
otherwise.
> operator
tool bool >(int left, int right)
tool bool >(long left, long right)
tool bool >(double left, double right)
Returns whether the first integer, long, or double number is greater than the second integer, long, or double number.
Arguments
-
left
-
The first integer, long, or double number.
-
right
-
The second integer, long, or double number.
Returns
true
if the first number is greater than the second number, false
otherwise.
>= operator
tool bool >=(int left, int right)
tool bool >=(long left, long right)
tool bool >=(double left, double right)
Returns whether the first integer, long, or double number is greater than or equal to the second integer, long, or double number.
Arguments
-
left
-
The first integer, long, or double number.
-
right
-
The second integer, long, or double number.
Returns
true
if the first number is greater than or equal to the second number, false
otherwise.
== operator
tool bool ==<T>(T left, T right)
Returns whether the first value is equal to the second value.
Type parameters
-
T
-
The type of the values.
Arguments
-
left
-
The first value. May be
null
. -
right
-
The second value. May be
null
.
Returns
true
if the first value is equal to the second value, false
otherwise.
!= operator
tool bool !=<T>(T left, T right)
Returns whether the first value is unequal to the second value.
Type parameters
-
T
-
The type of the values.
Arguments
-
left
-
The first value. May be
null
. -
right
-
The second value. May be
null
.
Returns
true
if the first value is unequal to the second value, false
otherwise.