上QQ阅读APP看书,第一时间看更新
Using map, reduce, and filter
Next, we'll look at a specialized set of standard library functions that take closure parameters:
- map returns an Array containing the results of applying a function to each item in a collection.
- filter returns a collection containing only those items of a collection that satisfy a specified match
- reduce returns a single value calculated by iterating through a collection, and applying a supplied function to each element and the accumulated results of the previous elements
Each of the functions and matches in this list are typically supplied as inline closures.