currying (was: Re: A trivial question about print)

Jeremy Bowers newsfroups at jerf.org
Fri Apr 12 17:52:07 EDT 2002


Huaiyu Zhu wrote:
> def f(a, b, c): return a+b+c
> f1 = curry(f, a, b)
> f1(c)
> map(curry(f, x, y), a)  # map(lambda z:f(x, y, z), a)
> 
> Huaiyu

Has anyone done any work on creating a more general curry function? One 
that might for instance curry the second of three positional arguments? 
Using the above definitions:

f2 = curry2(f, a, c)
f2(b)

I've used one-off curry functions for this, but I'm surprised that 
nobody seems to have considered this. (Maybe everybody just writes 
wrappers around functions?

def f2(a, c, b): return f(a,b,c)
f3 = curry(f, a, c)

)

Not a biggie, just curious. But I have had instances where I needed this 
type of currying.




More information about the Python-list mailing list