[Python-Dev] PEP 309, function currying

Andrew Koenig ark-mlist at att.net
Mon Feb 23 11:06:45 EST 2004


> > Here's what the abstract should say:
> >
> > Function currying is the process of transforming a function that expects
> > all of its arguments at once into a delayed function (called a curried
> > function) that expects the remainder of the arguments to be supplied.
> > Once all the arguments are supplied, the function evaluates normally.
> 
> But isn't that just as wrong as the first version? It still seems
> to be describing partial application, not currying as you defined
> it above. Maybe it should say
> 
>    Function currying is the process of transforming a function that
>    takes n arguments into a function that takes one argument and
>    returns another function (itself also curried, if n > 2) that
>    takes the remaining n-1 arguments.

Actually, we're both wrong.

I missed a level of indirection in trying to reuse words from the original
abstract where possible, so I missed that the "delayed function" must itself
return a function.  You missed that the function returned takes only one
argument, not n-1 arguments.

Perhaps this way will work:
 
	Function currying is the process of transforming a function that
	expects all of its arguments at once into a delayed function
	(called a curried function), that expects only its first argument.
	If the first argument is the only argument, currying is the
	identity function.  Otherwise, the delayed function, itself also
	curried, expects the first of the remaining arguments and yields
	either the result (if there is only one remaining argument) or
	a similarly delayed, curried function that deals with the second
	and subsequent remaining arguments.




More information about the Python-Dev mailing list