liveBook · Manning

Partial1

As explained in Functional Programming in Scala, Second Edition

partial1 is a book-defined function that partially applies a function by fixing one of its arguments and returning a function for the remaining argument.

partial1 fixes an argument of a two-argument function and returns a one-argument function for the remaining input. Its polymorphic type sharply constrains the implementation. section 2.5

Implementation

def partial1[A, B, C](a: A, f: (A, B) => C): B => C = (b: B) => f(a, b) The returned function captures a and supplies it to f whenever it receives b.

How Functional Programming in Scala, Second Edition covers it

How deep it goes
Derives the implementation from the type signature and stops short of broader operational details.
Examples
Demonstrates a polymorphic Scala definition that captures one argument and applies both arguments later.
What it assumes
Assumes basic Scala function syntax while teaching anonymous functions and higher-order function application through the example.
What you can do after
Build it from scratch by reading the return type and writing the only compiling function shape.
How it connects
Connects partial application with higher-order functions, currying, uncurrying, and function composition.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Programming in Scala, Second Edition. The section links point to the parts of the book it draws on.