Partially evaluated functions
Rainer Deyke
root at rainerdeyke.com
Wed Jun 20 00:16:08 EDT 2001
"Venkatesh Prasad Ranganath" <rvprasad at cis.ksu.edu> wrote in message
news:m3sngw12ce.fsf at boss.dreamsoft.com...
> Hi,
>
> I have used ML and it is interesting how it is possible to specialize a
function
> by partially evaluating when in curried form.
>
> Is partially evaluated functions possible in python? If there has been a
> discussion about it, where can I find the jist of the discussion?
>
> def conv(a, b, c):
> return (a + b) * c
>
> faren2cel = conv(b = -32, c = 5 / 9)
class curry:
def __init__(*args, **kwargs):
self = args[0]
self.function = args[1]
self.args = args[2:]
self.kwargs = kwargs
def __call__(*args, **kwargs):
kwargs.update(self.kwargs)
return self.function(self.args + args, kwargs)
faren2cel = curry(conv, b = -32.0, c = 5.0 / 9)
--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games - http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor
More information about the Python-list
mailing list