Name
listmap — Maps an operation onto all elements of a list and thus creates a map.
Synopsis
list
listmap
( |
any
| VAR
, |
|
list
| LIST
, |
|
block
| EXPR
) ; |
Parameters
-
any
VAR
-
list
LIST
-
block
EXPR
Description
For each element VAR of the list LIST in the expression EXPR is evaluated in a new context. The result is the map of those evaluations.
The result of each evaluation must be a map with a single entry which will be added to the result map.
Usage
listmap (integer k, [1,2,3], { return $[k, "xy"]; }) -> $[ 1:"xy", 2:"xy" ]
listmap (integer k, [1,2,3], { any a = k+10; any b = sformat ("x%1", k); map ret = $[a,b]; return ret; }) -> $[ 11:"x1", 12:"x2", 13:"x3" ]
|