Hacker News new | ask | show | jobs
by Jtsummers 1359 days ago
The original `f` was a binary function:

  f = lambda x, y: x + y
My updated curried `f` is a unary function, but it returns a unary function itself:

  f = lambda x: lambda y: x + y
That's what currying is. I just reused the name, if you prefer:

  curried_f = lambda x: lambda y: x + y
EDIT:

And note, it makes the partial application less explicit/verbose than the original, but the currying is very explicit because of Python's syntax.

  g = curried_f(3)
Is "just" a function call, while:

  g = lambda y: f(3, x)
does the same thing (functionally, at least) but the partial application is made explicit.