map
transform all values in a list or dict
(any xs, function f) -> any
If xs
is a list, returns a list of all items in xs
mapped through f
. If f
accepts one argument, the list element is passed. If f
accepts two arguments, the list element and its index are passed.
If xs
is a dict, returns a dict of all entries mapped through f
. If f
accepts one argument, each entry’s value is passed. If f
accepts two arguments, each entry’s value and key are passed.
Returns nil
if xs
is nil
or f
is nil
Throws an error if xs
is of any other type.
Parameters
Name | Type | Description |
---|---|---|
xs |
list or dict | The list or dict to transform |
f |
function |
A function of the form (any x, any k) -> any that transforms each item x at key or index k . |