# 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

### Ordering of values

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)

## Text operators

`~`

: is an alias for`uppercase()`

, usually used to make text operations case-insensitive:`contains(foo, "bar")`

is case-sensitive,`contains(~foo, ~"bar")`

is case-insensitive.`~~`

: case-insensitive equality`!~`

: the opposite of`~~`

`*`

: repeats text a specified number of times.`"ABC" * 3`

is`"ABCABCABC"`

.

## 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.

## Ranvars operators

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

`+*`

: additive convolution`-^`

: subtractive convolution`**`

: multiplicative convolution (Dirichlet convolution)`^*`

: convolution power

Translation of ranvars (left and right shifts) are performed by convolving the ranvar with the appropriate Dirac delta ranvar (see operation `+* dirac()`

).

## Zedfuncs operators

Zedfuncs benefit from specific operators (see also algebra of zedfuncs):

`+`

: point-wise addition`-`

: point-wise subtraction`*`

: point-wise multiplication`<<`

: left shift`>>`

: right shift

## 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`<<`

`*`

,`/`

,`/.`

and`mod`

`-`

,`+`

,`+*`

,`-*`

and`**`

`<`

,`<=`

,`==`

,`!=`

,`~~`

,`!~`

,`>`

,`>=`

,`~~`

and`!~`

`not`

`&`

`|`