Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the function curry called curry?

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.

like image 809
Teodorico Levoff Avatar asked Apr 13 '15 20:04

Teodorico Levoff


People also ask

How do curried functions work?

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.

Who invented Currying?

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.


2 Answers

It's named after Haskell Curry, who worked on the mathematical foundations of functional programming.

like image 175
SLaks Avatar answered Oct 01 '22 22:10

SLaks


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)
like image 29
MisterMetaphor Avatar answered Oct 01 '22 20:10

MisterMetaphor