All three functions return the correct output. However, you might be thinking…this is a lot of work. While we did remove the redundant code, we still had to write many small functions, which is the result of passing functions as parameters. It becomes tedious to have to define, name, and keep track of these functions. Scala solves this problem by introducing anonymous functions.
Before we move on to anonymous functions, try writing your own higher-order function in the next lesson.