
On Tue, Dec 16, 2008 at 3:40 AM, Mathias Panzenböck <grosser.meister.morti@gmx.net> wrote:
Thinking of it, we do not need any new syntax:
def curry(f): def _f(x). def _f2(*args,**kwargs): return f(x,*args,**kwargs) return _f2 return _f
@curry def foo(a,b,c): return a+b+c
This forces you to call foo(1)(2)(3) if you want an answer. How about: def curry(f): def _f(*c_args, **c_kwargs): def _f2(*args, **kwargs): return f(*c_args, *args, **c_kwargs, **kwargs) return _f2 return _f @curry def foo(a, b, c): return a + b + c foo(1, 2)(3) I think this still prevents us from currying multiple times --- that is, you curry once, and you get a non-curriable function. I remember something in the wiki about a decorator in the form of an object, that accumulated arguments when __call__()ed, and I think that worked best (and still didn't need new syntax). -- Cheers, Leif