# Currying

Cur­ry­ing con­verts a func­tion of N in­puts into a func­tion of a sin­gle in­put, which re­turns a func­tion that takes a sec­ond in­put, which re­turns a func­tion that takes a third in­put, and so on, un­til N func­tions have been eval­u­ated and N in­puts have been taken, at which point the origi­nal func­tion is eval­u­ated on the given in­puts and the re­sult is re­turned.

For ex­am­ple:

Con­sider a func­tion of four pa­ram­e­ters, $$F:(X,Y,Z,N)→R$$.

The cur­ried ver­sion of the func­tion, $$curry(F)$$ would have the type sig­na­ture $$X→(Y→(Z→(N→R)))$$, and $$curry(F)(4)(3)(2)(1)$$ would equal $$F(4,3,2,1)$$.

Cur­ry­ing is named af­ter the lo­gi­cian Haskell Curry. If you can’t re­mem­ber this deriva­tion and need a mnemonic, you might like to imag­ine a func­tion be­ing cooked in a curry so thor­oughly that it breaks up into small, bite-sized pieces, just as func­tional cur­ry­ing breaks a func­tion up into smaller func­tions. (It might also help to note that there is a pro­gram­ming lan­guage also named af­ter Haskell Curry (Haskell), that fea­tures cur­ry­ing promi­nently. All func­tions in Haskell are pre-cur­ried by con­ven­tion. This of­ten makes par­tially ap­ply­ing func­tions effortless.)

Parents:

• Mathematics

Math­e­mat­ics is the study of num­bers and other ideal ob­jects that can be de­scribed by ax­ioms.

• Function