Alex Rivera | Logout

Practical use of curried functions?

Asked 2011-02-03T16:04:31.760
29

There are tons of tutorials on how to curry functions, and as many questions here at stackoverflow. However, after reading The Little Schemer, several books, tutorials, blog posts, and stackoverflow threads I still don't know the answer to the simple question: "What's the point of currying?" I do understand how to curry a function, just not the "why?" behind it.

Could someone please explain to me the practical uses of curried functions (outside of languages that only allow one argument per function, where the necessity of using currying is of course quite evident.)

edit: Taking into account some examples from TLS, what's the benefit of

(define (action kind)
    (lambda (a b)
        (kind a b)))

as opposed to

(define (action kind a b)
    (kind a b))

I can only see more code and no added flexibility...

Edit
Report

1 Answer

3

I think that currying is a traditional way to handle general n-ary functions provided that the only ones you can define are unary.

For example, in lambda calculus (from which functional programming languages stem), there are only one-variable abstractions (which translates to unary functions in FPLs). Regarding lambda calculus, I think it's easier to prove things about such a formalism since you don't actually need to handle the case of n-ary functions (since you can represent any n-ary function with a number of unary ones through currying).

(Others have already covered some of the practical implications of this decision so I'll stop here.)

answered 2011-02-04T02:41:58.657

Your Answer