# Generic Functions and Operators​

 anytype = anytype Compare two values for equality. anytype != anytype Compare two values for inequality. anytype ?= anytype Compare two (potentially empty) values for equality. anytype ?!= anytype Compare two (potentially empty) values for inequality. anytype < anytype Less than operator. anytype > anytype Greater than operator. anytype <= anytype Less or equal operator. anytype >= anytype Greater or equal operator. len() A polymorphic function to calculate a "length" of its first argument. contains() A polymorphic function to test if a sequence contains a certain element. find() A polymorphic function to find index of an element in a sequence.
operator
anytype = anytype
anytype = anytype -> bool

Compare two values for equality.

Copy
`db> `
`SELECT 3 = 3.0;`
`{true}`
Copy
`db> `
`SELECT 3 = 3.14;`
`{false}`
Copy
`db> `
`SELECT [1, 2] = [1, 2];`
`{true}`
Copy
`db> `
`SELECT (1, 2) = (x := 1, y := 2);`
`{true}`
Copy
`db> `
`SELECT (x := 1, y := 2) = (a := 1, b := 2);`
`{true}`
Copy
`db> `
`SELECT 'hello' = 'world';`
`{false}`
operator
anytype != anytype
anytype != anytype -> bool

Compare two values for inequality.

Copy
`db> `
`SELECT 3 != 3.0;`
`{false}`
Copy
`db> `
`SELECT 3 != 3.14;`
`{true}`
Copy
`db> `
`SELECT [1, 2] != [2, 1];`
`{false}`
Copy
`db> `
`SELECT (1, 2) != (x := 1, y := 2);`
`{false}`
Copy
`db> `
`SELECT (x := 1, y := 2) != (a := 1, b := 2);`
`{false}`
Copy
`db> `
`SELECT 'hello' != 'world';`
`{true}`
operator
anytype ?= anytype
OPTIONAL anytype ?= OPTIONAL anytype -> bool

Compare two (potentially empty) values for equality.

Works the same as regular `=`, but also allows comparing `{}`. Two `{}` are considered equal.

Copy
`db> `
`SELECT {1} ?= {1.0};`
`{true}`
Copy
`db> `
`SELECT {1} ?= <int64>{};`
`{false}`
Copy
`db> `
`SELECT <int64>{} ?= <int64>{};`
`{true}`
operator
anytype ?!= anytype
OPTIONAL anytype ?!= OPTIONAL anytype -> bool

Compare two (potentially empty) values for inequality.

Works the same as regular `!=`, but also allows comparing `{}`. Two `{}` are considered equal.

Copy
`db> `
`SELECT {2} ?!= {2};`
`{false}`
Copy
`db> `
`SELECT {1} ?!= <int64>{};`
`{true}`
Copy
`db> `
`SELECT <bool>{} ?!= <bool>{};`
`{false}`
operator
anytype < anytype
anytype < anytype -> bool

Less than operator.

Return `true` if the value of the left expression is less than the value of the right expression. In EdgeQL any values can be compared to each other as long as they are of the same type:

Copy
`db> `
`select 1 < 2;`
`{true}`
Copy
`db> `
`select 2 < 2;`
`{false}`
Copy
`db> `
`select 'hello' < 'world';`
`{true}`
Copy
`db> `
`select (1, 'hello') < (1, 'world');`
`{true}`
operator
anytype > anytype
anytype > anytype -> bool

Greater than operator.

Return `true` if the value of the left expression is greater than the value of the right expression. In EdgeQL any values can be compared to each other as long as they are of the same type:

Copy
`db> `
`SELECT 1 > 2;`
`{false}`
Copy
`db> `
`SELECT 3 > 2;`
`{true}`
Copy
`db> `
`select 'hello' > 'world';`
`{false}`
Copy
`db> `
`select (1, 'hello') > (1, 'world');`
`{false}`
operator
anytype <= anytype
anytype <= anytype -> bool

Less or equal operator.

Return `true` if the value of the left expression is less than or equal to the value of the right expression. In EdgeQL any values can be compared to each other as long as they are of the same type:

Copy
`db> `
`SELECT 1 <= 2;`
`{true}`
Copy
`db> `
`select 2 <= 2;`
`{true}`
Copy
`db> `
`select 3 <= 2;`
`{false}`
Copy
`db> `
`select 'hello' <= 'world';`
`{true}`
Copy
`db> `
`select (1, 'hello') <= (1, 'world');`
`{true}`
operator
anytype >= anytype
anytype >= anytype -> bool

Greater or equal operator.

Return `true` if the value of the left expression is greater than or equal to the value of the right expression. In EdgeQL any values can be compared to each other as long as they are of the same type:

Copy
`db> `
`SELECT 1 >= 2;`
`{false}`
Copy
`db> `
`SELECT 2 >= 2;`
`{true}`
Copy
`db> `
`SELECT 3 >= 2;`
`{true}`
Copy
`db> `
`select 'hello' >= 'world';`
`{false}`
Copy
`db> `
`select (1, 'hello') >= (1, 'world');`
`{false}`
function
len()
std::len(value: str) -> int64std::len(value: bytes) -> int64std::len(value: array<anytype>) -> int64

A polymorphic function to calculate a “length” of its first argument.

Return the number of characters in a `str`, or the number of bytes in `bytes`, or the number of elements in an `array`.

Copy
`db> `
`SELECT len('foo');`
```{3}
```
Copy
`db> `
`SELECT len(b'bar');`
```{3}
```
Copy
`db> `
`SELECT len([2, 5, 7]);`
`{3}`
function
contains()
std::contains(haystack: str, needle: str) -> boolstd::contains(haystack: bytes, needle: bytes) -> boolstd::contains(haystack: array<anytype>, needle: anytype) -> bool

A polymorphic function to test if a sequence contains a certain element.

When the haystack is `str` or `bytes`, return `true` if needle is contained as a subsequence in it and `false` otherwise.

When the haystack is an `array`, return `true` if the array contains the specified element and `false` otherwise.

Copy
`db> `
`SELECT contains('qwerty', 'we');`
```{true}
```
Copy
`db> `
`SELECT contains(b'qwerty', b'42');`
```{false}
```
Copy
`db> `
`SELECT contains([2, 5, 7, 2, 100], 2);`
`{true}`
function
find()
std::find(haystack: str, needle: str) -> int64std::find(haystack: bytes, needle: bytes) -> int64std::find(haystack: array<anytype>, needle: anytype, from_pos: int64=0) -> int64

A polymorphic function to find index of an element in a sequence.

When the haystack is `str` or `bytes`, return the index of the first occurrence of needle in it.

When the haystack is an `array`, return the index of the first occurrence of the specific needle element. For `array` inputs it is also possible to provide an optional from_pos argument to specify the position from which to start the search.

If the needle is not found, return `-1`.

Copy
`db> `
`SELECT find('qwerty', 'we');`
```{1}
```
Copy
`db> `
`SELECT find(b'qwerty', b'42');`
```{-1}
```
Copy
`db> `
`SELECT find([2, 5, 7, 2, 100], 2);`
```{0}
```
Copy
`db> `
`SELECT find([2, 5, 7, 2, 100], 2, 1);`
`{3}`