Map
Creates a new list with the results the provided function called for every item of the list.
Description
The Map
brick creates a new list which items are the result values of the provided function (mapper) execution on every item of the original provided list.
In other words, Map
transforms each element of a list and is equivalent to Javascript's <a href="https://medium.com/@JeffLombardJr/understanding-foreach-map-filter-and-find-in-javascript-f91da93b9f2c" target="_blank">map()</a>
The output control flow is triggered when all items have been processed.
Example:
-
inputs:
- list:
[1, 4, 9, 16]
- mapper:
(x) => x * 2
- list:
-
outputs:
- resulting list: [2, 8, 18, 32]
Inputs
- Control Flow (Control Flow)
- list (List): The original list to iterate on.
- mapper (Mapper): The function to execute on every item of the list, providing the item of the new list.
Inputs:
-start (Control Flow)
: Triggered when the item is to be processed.
-item (Object)
: The current item of the list.
-rank (Number)
: The rank of the current item.
-list (List)
: The full list being iterated.
Outputs:
-end (Control Flow)
: Triggered when the processing is completed.
-output item (Object)
: The transformed item to be placed inreturning list
.
Outputs
- Control Flow (Control Flow)
- resulting list (List): The generated list with items resulting of the mapper function.