Chapter 9. Higher Order Functions

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 Scala Functional Programming Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.