Operators in the Flux language

Flux includes the following types of operators:

Arithmetic operators

Arithmetic operators take two numerical values (either literals or variables) and perform a calculation that returns a single numerical value.

Operator Description Example Result
+ Addition 1 + 1 2
- Subtraction 3 - 2 1
* Multiplication 2 * 3 6
/ Division 9 / 3 3
% Modulus 10 % 5 0

In the current version of Flux, values used in arithmetic operations must be of the same numeric type (integer or float). Operations with values of different numeric types will result in a type error.

Comparison operators

Comparison operators compare expressions and return true or false based on the comparison.

Operator Description Example Result
== Equal to "abc" == "abc" true
!= Not equal to "abc" != "def" true
< Less than 1 < 2 true
> Greater than 1 > 2 false
<= Less than or equal 1 <= 2 true
>= Greater than or equal 1 >= 2 false
=~ Equal to regular expression "abc" =~ /[a-z]*/ true
!~ Not equal to regular expression "abc" !~ /[0-9]*/ true

The > and < operators also compare the lexicographic order of strings.

Assignment operators

An assignment operator assigns a value to its left operand based on the value of its right operand.

Operator Description Example Meaning
= Assign value of left expression to right expression x = y x = y

Function operators

Function operators facilitate the creation of functions and control the flow of data through operations.

Operator Description Examples Meaning
|> Pipe‑forward data |> function() Tables contained in the “data” variable are piped into the function.
<- Pipe‑receive tables=<- The “tables” variable or parameter is assigned to data piped into the operation. This operator is used for any data type passed into a function; not just table data.
=> Arrow (r) => r.tag1 == "tagvalue" The arrow passes an object or parameters into function operations.
() Function call top(n:10) Call the top function setting the n parameter to 10 and perform the associated operations.

See Custom functions for examples of function operators is use.


String Operators

String operators concatenate or compare string values.

Operator Description Examples Result
+ Concatenation "ab" + "c" "abc"
< Less than in lexicographic order "ant" < "bee" true
> Greater than in lexicographic order "ant" > "bee" false

Literal constructors

Literal constructors define fixed values.

Operator Description
[ ] List / array
{ } Object
"" String

Miscellaneous operators

Operator Description Example
( ) Logical grouping r._value / (r._value * 2)
, Sequence delimiter item1, item2, item3
: Key-value separator {name: "Bob"}
. Dot reference r._measurement

This documentation is open source. See a typo? Please, open an issue.


Need help getting up and running? Get Support