Higher-order functions are widely used for functional programming. Swift provides many built-in higher-order functions such as map, filter, reduce, and compactMap 1. map The map function transforms each element in a collection by applying a closure. 2. filter The filter function filters elements of a collection based on a condition. …