New submission from Marko Nervo ma...@python.it:
I think it would be very usefull to add a curry function to the functools
module. It should be like this.
def curry(func, *args, **kwargs):
if (len(args) + len(kwargs)) = func.__code__.co_argcount:
return func(*args, **kwargs
Marko Nervo ma...@python.it added the comment:
In [1]: import functools
In [2]: def adder(x, y, z):
...: return (x + y + z)
...:
In [3]: adder = functools.partial(adder)
In [4]: adder(2)(3)(4)
---
TypeError
Marko Nervo ma...@python.it added the comment:
I totally disagree with the syntax for curried function, but I think a curry
function is perfect for the functools module and I also think it could be
useful at least as functools.partial. In addition, a lot of languages support
currying
Marko Nervo ma...@python.it added the comment:
But so does functools.partial. So the question is, what use case does it
help that functools.partial doesn't?
Sure, it's common `defining new functions on other functions`... more times.
Here a stupid example with fold (our reduce).
@curry
def
Marko Nervo ma...@python.it added the comment:
You will have to try a bit
harder and showcase examples of *useful* code that are made
significantly easier through the use of curry().
Curry is a more advanced functools.partial. So, it could be used *at least* as
partial, but it is more