Information About

Currying




In Computer Science , currying, invented by Moses Schönfinkel and Gottlob Frege , is the technique of transforming a Function that takes multiple Arguments into a function that takes a single argument (the other arguments having been specified by the curry).


NOMENCLATURE

The name "currying", coined by Christopher Strachey in 1967, is a reference to logician Haskell Curry . An alternative name, ''Schönfinkelisation'', has been proposed. I. Heim and A. Kratzer (1998). ''Semantics in Generative Grammar''. Blackwell.


DEFINITION


Given a function ''f'' of type f \colon (X imes Y) o Z , then currying it makes a function \mbox{curry}(f) \colon X o (Y o Z) . That is, \mbox{curry}(f) takes an argument of type X and returns a function of type Y o Z . '''Uncurrying''' is the reverse transformation.

Intuitively, currying says "if you fix some Argument s, you get a function of the remaining arguments". For example, if function ''div'' stands for the curried form of the division operation /, then ''div''(1) is another function: the same as the function ''inv'' that returns the multiplicative inverse of its argument, defined by ''inv''(''y'') = 1 / ''y''.

The practical motivation for currying is that very often the functions you get by supplying some but not all of the arguments to a curried function are useful; for example, many languages have a function or operator similar to plus_one. Currying makes it easy to define these functions.

Some Programming Language s have built-in syntactic support for currying, where certain multi-argument functions are expanded to their curried form; notable examples are ML and Haskell . Any language that supports Closure s can be used to write curried functions.


MATHEMATICAL VIEW


In Theoretical Computer Science , currying provides a way to study functions with multiple arguments in very simple theoretical models such as the Lambda Calculus in which functions only take a single argument.

When viewed in a set-theoretic light, currying becomes the Theorem that the set
A^{B imes C} of functions from
B imes C to A, and the set (A^B)^C of functions from
C to the set of functions from B to A,
are Isomorphic .

In Isomorphism between the Morphism s from a Binary Product f \colon (X imes Y) o Z and the morphisms to an exponential object g \colon X o Z^Y . In other words, currying is the statement that Product and Hom are Adjoint Functors ;
this is the key property of being a Cartesian Closed Category .


SEE ALSO




REFERENCES



EXTERNAL LINKS