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

Generic - 图1

anytype = anytype -> bool

Compare two values for equality.

  1. select 3 = 3.0;
  1. {true}
  1. select 3 = 3.14;
  1. {false}
  1. select [1, 2] = [1, 2];
  1. {true}
  1. select (1, 2) = (x := 1, y := 2);
  1. {true}
  1. select (x := 1, y := 2) = (a := 1, b := 2);
  1. {true}
  1. select 'hello' = 'world';
  1. {false}

operator

anytype != anytype

Generic - 图2

anytype != anytype -> bool

Compare two values for inequality.

  1. select 3 != 3.0;
  1. {false}
  1. select 3 != 3.14;
  1. {true}
  1. select [1, 2] != [2, 1];
  1. {false}
  1. select (1, 2) != (x := 1, y := 2);
  1. {false}
  1. select (x := 1, y := 2) != (a := 1, b := 2);
  1. {false}
  1. select 'hello' != 'world';
  1. {true}

operator

anytype ?= anytype

Generic - 图3

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.

  1. select {1} ?= {1.0};
  1. {true}
  1. select {1} ?= <int64>{};
  1. {false}
  1. select <int64>{} ?= <int64>{};
  1. {true}

operator

anytype ?!= anytype

Generic - 图4

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.

  1. select {2} ?!= {2};
  1. {false}
  1. select {1} ?!= <int64>{};
  1. {true}
  1. select <bool>{} ?!= <bool>{};
  1. {false}

operator

anytype < anytype

Generic - 图5

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:

  1. select 1 < 2;
  1. {true}
  1. select 2 < 2;
  1. {false}
  1. select 'hello' < 'world';
  1. {true}
  1. select (1, 'hello') < (1, 'world');
  1. {true}

operator

anytype > anytype

Generic - 图6

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:

  1. select 1 > 2;
  1. {false}
  1. select 3 > 2;
  1. {true}
  1. select 'hello' > 'world';
  1. {false}
  1. select (1, 'hello') > (1, 'world');
  1. {false}

operator

anytype <= anytype

Generic - 图7

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:

  1. select 1 <= 2;
  1. {true}
  1. select 2 <= 2;
  1. {true}
  1. select 3 <= 2;
  1. {false}
  1. select 'hello' <= 'world';
  1. {true}
  1. select (1, 'hello') <= (1, 'world');
  1. {true}

operator

anytype >= anytype

Generic - 图8

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:

  1. select 1 >= 2;
  1. {false}
  1. select 2 >= 2;
  1. {true}
  1. select 3 >= 2;
  1. {true}
  1. select 'hello' >= 'world';
  1. {false}
  1. select (1, 'hello') >= (1, 'world');
  1. {false}

function

len()

Generic - 图9

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.

  1. select len('foo');
  1. {3}
  1. select len(b'bar');
  1. {3}
  1. select len([2, 5, 7]);
  1. {3}

function

contains()

Generic - 图10

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.

  1. select contains('qwerty', 'we');
  1. {true}
  1. select contains(b'qwerty', b'42');
  1. {false}
  1. select contains([2, 5, 7, 2, 100], 2);
  1. {true}

function

find()

Generic - 图11

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.

  1. select find('qwerty', 'we');
  1. {1}
  1. select find(b'qwerty', b'42');
  1. {-1}
  1. select find([2, 5, 7, 2, 100], 2);
  1. {0}
  1. select find([2, 5, 7, 2, 100], 2, 1);
  1. {3}