# List of operators

The operators are algebraic primitives powering Envision. Below, we list the operators supported by Envision.

## Generic operators

The following operators are supported by all types:

`==`

: equality (case-sensitive when comparing text)`!=`

: inequality (case-sensitive when comparing text)`<`

: less than`>`

: greater than`<=`

: less than or equal to`>=`

: greater than or equal to`~`

: operator makes a text case-insensitive, e.g., contains(foo, “bar”) is case-sensitive, whereas contains(~foo, ~“bar”) is case-insensitive`~~`

: case-insensitive equality (restricted to text comparison)`!~`

: inequality reversing`~~`

Ordering of values is the same for all Envision constructs (such as `order by`

, `rank`

or `median`

):

- numbers are sorted in ascending order
- dates are sorted in chronological order
`false < true`

- text values are sorted in alphabetical order (specifically, by Unicode code points)

## Numeric operators

The following numeric operators are supported:

`+`

: addition`-`

: subtraction`*`

: multiplication`/`

: division`/.`

: division hardened against division by zero,`a /. b`

returns 0 if`b == 0`

, and the regular division otherwise.`mod`

: remainder of the integer division`^`

: power

Some numeric operators can be used for dates:

`date - date`

is the number of days between two dates`date + number`

and`date - number`

adds or subtracts days to a date

## Logical operators

The following logical operators are supported:

`&`

: logical AND`|`

: logical OR`not`

: logical NOT`c ? a : b`

: the conditional operator, also referred to as the*ternary if*. Note that`a`

,`b`

and`c`

are first evaluated separately.

## Distribution operators

Distributions benefit from specific operators (see also algebra of ranvars):

`+`

: point-wise addition`-`

: point-wise subtraction`*`

: point-wise multiplication`<<`

: left shift`>>`

: right shift

### Random variable operators

When distributions happen to be random variables (mass is equal to 1, no negative values), they benefit from specific operators:

`+*`

: additive convolution`-^`

: subtractive convolution`**`

: multiplicative convolution (Dirichlet convolution)`^*`

: convolution power

## Operator precedence

The operators below are listed in increasing order of precedence. For instance, since `&`

is before `|`

, then `A | B & C`

is interpreted as `A | (B & C)`

. Operators with the same precedence are grouped left-to-right: `A * B / C`

is `(A * B) / C`

.

`^`

,`^*`

,`>>`

,`<<`

`*`

,`/`

,`/.`

and`mod`

`-`

,`+`

,`+*`

,`-*`

,`**`

`<`

,`<=`

,`==`

,`!=`

,`~~`

,`!~`

,`>`

,`>=`

,`~~`

and`!~`

`not`

`&`

`|`