Why doesn't this simple Curry-like implemention work?

J.Jacob joost_jacob at hotmail.com
Sun Oct 28 13:04:29 CET 2001


"Michael R. Head" <burner at core.binghamton.edu> wrote in message news:<mailman.1004250686.9471.python-list at python.org>...
> # for some reason this function doesn't work in python 1.5.2.
> def curry(f, p):
> 	return lambda x: apply(f, p, x)
> 
I'm supposing that lamda isn't storing
> the reference to its inputs -- which it seems it should -- is this
> correct?
> mike

Try this:
def curry(f, p):
	return lambda x, ff=f, pp=p: apply(ff, pp, x)
But i wonder if it does what you want <wink>

Joost



More information about the Python-list mailing list