mapkey
mapkey(
@llll ## llll (required)
@key ## symbol (required)
@func ## lambda function (required)
) -> llll
Modifies an existing llll
key via a lambda function, with signature ($x, $llll -> $y)
. It assumes the llll consists of key-value pairs, and is wrapped at the top level, like so:
[
[ '<key1>' <value1> ]
[ '<key2>' <value2> ]
...
[ '<keyN>' <valueN> ]
]
Arguments
@llll
[llll]:llll
to modify. (required)@key
[symbol]: Name ofllll
key. (required)@func
[lambda function]: Lambda function. (required)
Output
Modified llll
[llll]
Usage
$nums = [["one" 1] ["two" 2]];
$func = ($val -> $val :* 4);
$nums = $nums.mapkey("one", $func); ## re-assign to update
print($nums) ## [["one" 1 1 1 1] ["two" 2]]