
Swift Functional Programming
By :

In this chapter, we started with the category theory concepts such as Functor
, Applicative Functor
, and Monad, and explored higher-order functions such as map
, filter
, flatMap
, joined
, and reduce
. Then, we examined Swift-provided versions of higher-order functions and implemented a simple version ourselves. Also, we developed map
, filter
, flatMap
, and flatten
functions in terms of the reduce
function.
Then, we continued with the apply
, join
, and zip
functions and were introduced to chaining higher-order functions.
Finally, we explored some practical examples of higher-order functions such as removing nil
values from an array, removing duplicates, and partitioning arrays.
These functions are going to be great tools in our day-to-day development toolkit to use and solve a lot of different kinds of problem.
In the following chapter, we will get familiar with optional types and discuss non- functional and functional ways to deal with them.