Lambda
ReQL Lambda functions can be used for computations on sets of values.
Lambda functions take two arguments: a lambda expression and a set.
Lambda functions evaluate the lambda expression on every element of the set. The lambda expression can be any valid ReQL expression, and therefore can contain for example item properties or functions.
| Name | Description | Example |
|---|---|---|
| map | Applies the lambda expression to every member of a set | |
| select | Returns only those values of input set for which the lambda expression returns true | |
| exists | Returns true if lambda expression is satisfied for at least one element of the input set |
Map
Map applies the expression to every element and returns the result as set.
Definition
| Argument | Type |
|---|---|
| lambda expression |
|
| input_set |
|
Examples
All the following expressions result in true:
Select
Select returns only those values of input set for which the lambda expression returns true. The lambda expression have to return a boolean.
Definition
| Argument | Type |
|---|---|
| lambda expression |
|
| input_set |
|
Examples
All the following expressions result in true:
Exists
Exists returns true if lambda expression returns true for at least one element of the input set. Otherwise returns false.
exists(lambda 'x': ...) can be though as shorthand for size(select(lambda 'x': ...)) > 0.
Definition
| Argument | Type |
|---|---|
| lambda expression |
|
| input_set |
|
Examples
All the following expressions result in true: