Currying a Function with Two Arguments

Currying expresses an operation on several arguments as a chain of functions, each taking one argument.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Follow a two-step call
  2. Distinguish the interface

Follow a two-step call

A curried addition can take 3 and return a function that adds three to any later value. Calling that result at 5 gives eight. Lexical closures explain how the first value remains available.

Distinguish the interface

An ordinary two-argument addition can be partially applied to fix three. Its original interface stays two-argument. In a curried design the staged form is the interface itself. See fixing a function argument for that separate adaptation.[1]

References

  1. Python Software Foundation, Functional Programming HOWTO ↩