CSC/ECE 517 Fall 2011/ch1 2a sd
Introduction
Currying is a technique used in Computer Science and Mathematics to transform a function with multiple parameters into multiple functions with one parameter. A function can either be thought of as having n arguments or a function with 1 argument that maps to another function with n-1 arguments.
In contrast, there is also uncurrying. Uncurrying is a technique of transforming a one argument function into a function with many arguments.
The notion is that a function of n arguments can be thought of as a function of 1 argument that maps to a function of n−1 arguments
Background
Currying was first discovered by Moses Schönfinkel, a Russian Logician, in 1924[1] and later re-discovered by Haskel Curry, an American Mathematician and Logician. Although Schönfinkel was the first to discover it, the process was ultimately named after Curry. For this reason, some people thought a more appropriate name would be Schönfinkeling.
Why is it Important?
Mathematical Definition
A function can be defined as f(x, y, z) -> g where it takes in three arguments x, y and z and returns q. To express this in curried form, the function would need to be split into multiple functions with only one argument. The new function can be written in the form f(x) -> (y -> (z -> q)). The function f takes in x as an argument and returns another function which takes in y as an argument. That function then returns another function which takes in z as an argument and returns q. A function, f(x, y, z) -> q, can be expressed in its curried form, F(x) -> (y -> (z -> q)).
Currying v.s. Partial Function
There is a small distinction between currying and partial functions. A Partial function simplifies another function by making one or more of its arguments constant. In contrast a curried function takes in one parameter and returns ...
Currying in Programming
Currying is used in several programming languages.