|
In mathematics and computer science, currying is the technique of translating the evaluation of a function that takes multiple arguments (or a tuple of arguments) into evaluating a sequence of functions, each with a single argument. It was introduced by Moses Schönfinkel〔 (Reprinted lecture notes from 1967.)〕〔Kenneth Slonneger and Barry L. Kurtz. ''Formal Syntax and Semantics of Programming Languages''. p. 144.〕 and later developed by Haskell Curry.〔Henk Barendregt, Erik Barendsen, "(Introduction to Lambda Calculus )", March 2000, page 8.〕 Uncurrying is the dual transformation to currying, and can be seen as a form of defunctionalization. It takes a function ''f''(''x'') that returns another function ''g''(''y'') as a result, and yields a new function that takes a number of additional parameters and applies them to the function returned by function ''f''. The process can be iterated. ==Motivation== There are analytical techniques that can only be applied to functions with a single argument. Practical functions frequently take more arguments than this. Frege showed that it was sufficient to provide solutions for the single argument case, as it was possible to transform a function with multiple arguments into a chain of single-argument functions instead. This transformation is the process now known as currying. Currying is similar to the process of calculating a function of multiple variables for some given values on paper. For example, given the function : :To evaluate , first replace with :Since the result is a function of , this new function can be defined as :Next, replace the argument with , producing 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 that currying, while similar, is not the same operation as partial function application. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Currying」の詳細全文を読む スポンサード リンク
|