Map
Syntax
$set.map($func)
Description
Applies the function func
to each element of the set
and returns the set of evaluation results.
Used when the result of the mapping is relevant. If the side effect (see Transactions) of the function func
is to be considered instead, then foreach() is used as an alternative.
If the result of the function is a set, then the result set must be flattened afterwards, since sets of sets are not supported as final results of expressions
Parameters
Name | Type | Description | Mandatory | Default |
---|---|---|---|---|
set | Set | A set to whose elements func should be applied to. |
yes | |
func | Function | Function to be applied to all elements of set . |
yes |
Return value
Type: Set
A set containing all evaluation results of the function func
for all elements in set
.
Examples
Addition
list(1, 4, 9)
.map(x -> $x + 5)
Output: A set with the elements [6, 9, 14].