related topics
{math, number, function}
{food, make, wine}

In mathematics and computer science, currying is the technique of transforming a function that takes multiple arguments (or an n-tuple of arguments) in such a way that it can be called as a chain of functions each with a single argument. It was invented by Moses Schönfinkel and later re-invented by Haskell Curry,[1][not specific enough to verify]

Uncurrying is the dual transformation to currying, and can be seen as a form of defunctionalization. It takes a function f(x) which returns another function g(y) as a result, and yields a new function f'(x, y) which takes a number of additional parameters and applies them to the function returned by f. The process can be iterated if necessary.



Currying is similar to the process of calculating a function of multiple variables for some given values on paper. For example, given the function f(x,y) = y / x:

On paper, using classical notation, this is usually done all in one step. However, each argument can be replaced sequentially as well. Each replacement results in a function taking exactly one argument. This produces a chain of functions as in lambda calculus, and multi-argument functions are usually represented in curried form.

Some programming languages almost always use curried functions to achieve multiple arguments; notable examples are ML and Haskell, where in both cases all functions have exactly one argument.

This is similar in computer code: If we let f be a function f(x,y) = y / x, then the function g_x(y) = (y \mapsto f(x,y)) is a curried version of f. In particular, g_{(2)}(y) = (y \mapsto f(2,y)) is the curried equivalent of the example above. Though note that currying, while similar, is not the same operation as partial function application.

Full article ▸

related documents
Closed set
Binary operation
General number field sieve
Quadratic programming
Domain (mathematics)
Graph of a function
Alexandroff extension
Heap (data structure)
Fibonacci coding
Waring's problem
Hamming distance
Alternating group
Pseudometric space
Degenerate distribution
Bernoulli process
Unique factorization domain
Equality (mathematics)
Geometric mean
Static code analysis
Zeta distribution
Snake lemma
Haar wavelet
Differential cryptanalysis
Boundary (topology)
Data integrity