![]() | ![]() | ![]() | Currying | Documentation and user's manual | Table of contents | OCaml programs |
Currying is the technique of transforming a function that takes multiple arguments into a function that takes a single argument (the first of the arguments to the original function) and returns a new function that takes the remainder of the arguments and returns the result. |
Uncurrying is the reverse transformation. |
This a definition of the function (named curry ) that computes the curried version of a function with two arguments:
|
Here are applications of curry that return functional values previously written:
|
This a definition of the function (named uncurry ) that uncurries the curried version of a function with two arguments:
|
|
Here are applications of curry that computes addition of two integers, multiplication of two real numbers and concatenation of two strings:
|
![]() | ![]() | ![]() | Currying | Documentation and user's manual | Table of contents | OCaml programs |