Map, filter, reduce

The functions in the Iteration
module can be used for functional-style transformation of data structures. Map
, for example, takes in a list and a function handler, and applies the function to every item in the list, returning a new list of transformed values. This is a convenient way of performing arbitrary transformations on items in lists.
The Iteration
module contains a set of these functions that operate on lists using handler functions that, when chained together, can be used to perform a variety of transformations.
The most important ones are
Map
- used to transform each item into new itemsFilter
- used to filter out items in the list that don't pass some criterionReduce
- used to reduce a list into a single item, like for example summing up a list of numbersFind
- used to find a specific item that matches some criterion
Anonymous function handlers
One can assign an anonymous function to the handler property by clicking the f-icon that appears when hovering the property of certain functions, like the ones in the Iteration
namespace. Read more about anonymous functions here.
Last updated
Was this helpful?