Function Currying
Bill Baxter
dnewsgroup at billbaxter.com
Wed Nov 15 16:38:57 PST 2006
David Medlock wrote:
> David Medlock wrote:
>
>>
>> Nice walter.
>>
>> Its too bad though that inner function delegates don't live past the
>> stack frame or this wouldn't really be necessary..hehe.
>>
>> -DavidM
>
> Oh yes I will add another plug for a great book which explains currying
> in the context of functions as well as programs:
>
> http://www.dina.dk/~sestoft/pebook/
>
>
Oh yeh... that's the reason I had "partial evaluation" on the brain when
I should have been saying "partial application". I looked over that
link the last time you posted it, too.
From what I gather from that web page and a quick google for "partial
evaluation", it is a much more advanced beast than partial function
application. In partial evaluation you'd take something like
triple_integral(fx,fy,fz) that integrates over three variables, and your
partial evaluation usage would be:
single_integral = partial_eval(triple_integral, gx, gy);
answer = single_integral(gz);
Looks just like partial application, except in partial evaluation, the
first two variables would actually be precomputed (integrated out) to
create a new function that really did not require gx and gy to perform
its computation.
Is that the way you understand it, too, David?
If so then there ain't no simple 1-page template that's going to be able
to do that for the general case. :-) But it would be mighty cool if
there were.
--bb
More information about the Digitalmars-d
mailing list