- Method map
funto the elements in
arrand collects the results.
arris treated as a set of elements, as follows:
funis applied in order to each element. The results are collected, also in order, to a value of the same type as
arr, which is returned.
funis applied to the values, and each result is assigned to the same index in a new mapping, which is returned.
The program is treated as a mapping containing the identifiers that are indexable from it and their values.
If there is a lfun::cast method in the object, it's called to try to cast the object to an array, a mapping, or a multiset, in that order, which is then handled as described above.
funis applied in different ways depending on its type:
funis called for each element. It gets the current element as the first argument and
extraas the rest. The result of the call is collected.
funis used as a function like above, i.e. the lfun::`() method in it is called.
funis indexed with each element. The result of that is collected.
- "zero or left out"
Each element that is callable is called with
extraas arguments. The result of the calls are collected. Elements that aren't callable gets zero as result.
Each element is indexed with the given string. If the result of that is zero then a zero is collected, otherwise it's called with
extraas arguments and the result of that call is collected.
This is typically used when
arris a collection of objects, and
funis the name of some function in them.
The function is never destructive on
- See also