Contrast With Partial Function Application
Currying and partial function application are often conflated. The difference between the two is clearest for functions taking more than two arguments.
Given a function of type, currying produces . That is, while an evaluation of the first function might be represented as, evaluation of the curried function would be represented as, applying each argument in turn to a single-argument function returned by the previous invocation. Note that after calling, we are left with a function that takes a single argument and returns another function, not a function that takes two arguments.
In contrast, partial function application refers to the process of fixing a number of arguments to a function, producing another function of smaller arity. Given the definition of above, we might fix (or 'bind') the first argument, producing a function of type . Evaluation of this function might be represented as . Note that the result of partial function application in this case is a function that takes two arguments.
Intuitively, partial function application says "if you fix the first arguments of the function, you get a function of the remaining arguments". For example, if function div stands for the division operation x/y, then div with the parameter x fixed at 1 (i.e., 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 partial application is that very often the functions obtained by supplying some but not all of the arguments to a function are useful; for example, many languages have a function or operator similar to plus_one. Partial application makes it easy to define these functions, for example by creating a function that represents the addition operator with 1 bound as its first argument.
Read more about this topic: Currying
Famous quotes containing the words contrast with, contrast, partial, function and/or application:
“By contrast with history, evolution is an unconscious process. Another, and perhaps a better way of putting it would be to say that evolution is a natural process, history a human one.... Insofar as we treat man as a part of naturefor instance in a biological survey of evolutionwe are precisely not treating him as a historical being. As a historically developing being, he is set over against nature, both as a knower and as a doer.”
—Owen Barfield (b. 1898)
“In contrast to revenge, which is the natural, automatic reaction to transgression and which, because of the irreversibility of the action process can be expected and even calculated, the act of forgiving can never be predicted; it is the only reaction that acts in an unexpected way and thus retains, though being a reaction, something of the original character of action.”
—Hannah Arendt (19061975)
“You must not be partial in judging: hear out the small and the great alike; you shall not be intimidated by anyone, for the judgment is Gods.”
—Bible: Hebrew, Deuteronomy 1:17.
“To look backward for a while is to refresh the eye, to restore it, and to render it the more fit for its prime function of looking forward.”
—Margaret Fairless Barber (18691901)
“It would be disingenuous, however, not to point out that some things are considered as morally certain, that is, as having sufficient certainty for application to ordinary life, even though they may be uncertain in relation to the absolute power of God.”
—René Descartes (15961650)