Currying
From Wikipedia, the free encyclopedia
|
This article is about the function transformation technique. For the dish, see Curry.
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).
NomenclatureThe name "currying", coined by Christopher Strachey in 1967, is a reference to logician Haskell Curry. An alternative name, Schönfinkelisation, has been proposed. [1] DefinitionGiven a function f of type Failed to parse (Missing texvc executable; please see math/README to configure.): f \colon (X \times Y) \to Z , then currying it makes a function Failed to parse (Missing texvc executable; please see math/README to configure.): \mbox{curry}(f) \colon X \to (Y \to Z) . That is, Failed to parse (Missing texvc executable; please see math/README to configure.): \mbox{curry}(f) takes an argument of type Failed to parse (Missing texvc executable; please see math/README to configure.): X and returns a function of type Failed to parse (Missing texvc executable; please see math/README to configure.): Y \to Z . Uncurrying is the reverse transformation. In a different sense, the opposite of currying is Apply, in that Apply will restore the curried argument. Intuitively, currying says "if you fix some arguments, you get a function of the remaining arguments". For example, if function div stands for the curried form of the division operation x / y, then div with the parameter x fixed at 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 obtained 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 Some programming languages 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 closures can be used to write curried functions. Mathematical viewIn 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 Failed to parse (Missing texvc executable; please see math/README to configure.): A^{B\times C} of functions from Failed to parse (Missing texvc executable; please see math/README to configure.): B\times C to Failed to parse (Missing texvc executable; please see math/README to configure.): A , and the set Failed to parse (Missing texvc executable; please see math/README to configure.): (A^B)^C of functions from Failed to parse (Missing texvc executable; please see math/README to configure.): C to the set of functions from Failed to parse (Missing texvc executable; please see math/README to configure.): B to Failed to parse (Missing texvc executable; please see math/README to configure.): A , are isomorphic. In category theory, currying can be found in the universal property of an exponential object, which gives rise to the following adjunction in cartesian closed categories: There is a natural isomorphism between the morphisms from a binary product Failed to parse (Missing texvc executable; please see math/README to configure.): f \colon (X \times Y) \to Z and the morphisms to an exponential object Failed to parse (Missing texvc executable; please see math/README to configure.): g \colon X \to 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 alsoReferences
External linksLook up currying in Wiktionary, the free dictionary.
fr:Curryfication it:Applicazione parziale ja:カリー化 pl:Currying |


