In many list processing languages (and other languages as well) they have a function called curry, which does some neat things. My question is why do they call it curry? Where does this name come from? My only guess would be the tasty curry dishes from various countries in the world but I can't see any relation with this and the functions behaviour.
In other terms, currying is when a function — instead of taking all arguments at one time — takes the first one and returns a new function, which takes the second one and returns a new function, which takes the third one, etc. until all arguments are completed.
Curry may be thought of as any Indian or Indian-style dish, usually with a sauce. But it is not a concept well recognised in India despite many Indian dishes fitting this description. It really began with the British, resident in India during the 18th and 19th centuries.
It's named after Haskell Curry, who worked on the mathematical foundations of functional programming.
The concept itself is named after Haskell Curry, who developed it.
Currying is basically translating a function of N arguments to a 'tree' of N nested functions, each taking one argument.
In Haskell, the curry
function converts a function of two arguments to a function of one argument that returns another function of one argument, which will finally return the result. It has the type:
curry :: ((a, b) -> c) -> a -> b -> c
Its implementation is shorter than the type definition:
curry f x y = f (x, y)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With