O'Reilly logo

Scala Design Patterns by Ivan Nikolov

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

Partial functions

In mathematics, and as a consequence in programming, there are functions that are not defined for all possible inputs. A simple example will be the square root function—it will only work for real numbers if they are non-negative. In this section, we will look at partial functions and how we can use them.

Partial functions are not partially applied functions

There seems to be some confusion around what partial functions are and what they are not. It is important for you to understand that these functions are not partially applied functions. Partially applied functions are simply functions that might take multiple parameters and we've specified some of them and then they return functions with fewer parameters that we can specify. ...

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