O'Reilly logo

Functional Programming: A PragPub Anthology by Michael Swaine

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Higher-Order Functions

The other aspect of functional style is working with higher-order functions—this is the facility that treats functions as first-class citizens. It lets us pass functions to functions, create functions within functions, and return functions from functions. This in turn allows for functional composition, and a virtue of Scala is that we can design using both functional composition and object composition, as we desire or as appropriate.

Let’s explore Scala’s approach to functional programming with some examples. We’ll start with some small examples that just manipulate numbers so we can easily grasp how to use higher-order functions in Scala. And then we’ll look at a practical example where we apply the concepts we’ve learned. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required