In the last chapter, we saw how the use of combinators simplifies code. We just have to pass in functions and not worry about the boilerplate of writing loops or creating pipelines.
The idea behind all this is that higher order functions can take other functions as parameters, return a function as a result, or do both. In Scala, as we already know, functions are first-class citizens. This is a rather neat idea, as we will soon see.
In this chapter, we will start with the strategy pattern and see the Java implementation. Then, we will change gears and see how this pattern is really not needed when you talk about Scala. This is largely the effect of being able to send across functions and function literals. Once we get used to passing around functions, we will look at three patterns that are related to high-order functions. In the same context, we will also take a closer look at the map method.
The first pattern is Functor. We will see what it is and how it is...