In problem solving and functional programming, currying is the practice of simplifying the execution of a function that takes multiple arguments into executing sequential single-argument functions. In simple terms, Currying is used to transform multiple-argument function into single argument function by evaluating incremental nesting of function arguments. Currying also mends one argument to another forms a relative pattern while execution.
Mathematical Illustration of Currying:
In general currying of functions takes up any number of calculations and data to single real function that returns an expected output. Here we take,
f(x, y) = (x*x*x) + (y*y*y) h(x) = (x*x*x) h(y) = (y*y*y) h(x)(y) = h(x)+h(y) f(x, y) = h(x)(y) Curry f = h(x)(y)
For example, we will take chaining the composition of function.
a(x) = b(c(d(x)))
v(a, b, c, d, e) = w(x(y(z(a, b, c, d, e))))
10 20 30 40 50
Here, the concept is nesting of one function to another function and hence the result of one function gets recorded in the chain of functions. There by simplifying one huge block of manipulation to simpler sequential blocks.
Code #1: Change kilometer to meter and meter to centimeter.
- Python | dir() function
- Python map() function
- id() function in Python
- Python | int() function
- Help function in Python
- sum() function in Python
- ord() function in Python
- Python | hex() function
- Python | cmp() function
- Python | oct() function
- Python | now() function
- Python | How to get function name ?
- Python | locals() function
- Python | fmod() function
- Function Annotations in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.