Currying - Motivation

Motivation

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:

To evaluate f(2,3), first replace x with 2.
Since the result is a function of y, this function g(y) can be defined as g(y) = f(2,y) = y/2.
Next, replace the y argument with 3, producing g(3) = f(2,3) = 3/2.

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.

If we let f be a function

then the function h where

is a curried version of . Here, is a function that maps an argument y to result z. In particular,

is the curried equivalent of the example above. Note, however, that currying, while similar, is not the same operation as partial function application.

Read more about this topic:  Currying

Other articles related to "motivation, motivations":

Anselm Of Canterbury - Biography - Conflicts With King Henry I - Motivation
... Vaughn reads Anselm's motivation in the lay investiture conflict as advancing the interests of the see of Canterbury, rather than those of the Church at large ...
Motivation - Applications - Games
... Motivational models are central to game design, because without motivation a player will not be interested in progressing further within a game ... Several models for gameplay motivations have been proposed, including Richard Bartle's ... has proposed a four-quadrant model of gameplay motivation that includes cooperation, competition, immersion and achievement ...
Mr. Motivation - Plot
... Motivation to boost his self-confidence ... Motivation appears to be a cheesy toy with cheesy phrases, until it says a phrase, out loud, that helps Charlie ask his co-worker Linda out on a date ... Motivation talk, throws him down a garbage chute ...

Famous quotes containing the word motivation:

    Self-determination has to mean that the leader is your individual gut, and heart, and mind or we’re talking about power, again, and its rather well-known impurities. Who is really going to care whether you live or die and who is going to know the most intimate motivation for your laughter and your tears is the only person to be trusted to speak for you and to decide what you will or will not do.
    June Jordan (b. 1939)