All you need is to first define this general but strange-looking function:
function Y(function f)
{ return lambda(mixed y) { return (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }) (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }, y); }; }
It took me quite a while to try to remember what the function looks like, and then write it in pike ;-)
Wouldn't this be easier:
function Y(function f) { function Z(mixed ... y) { return f(Z, @y); }; return Z; }
/ Fredrik (Naranek) Hubinette (Real Build Master)
Previous text:
2003-10-06 09:25: Subject: Re: Some tasks from the conference
o Implement this_function().
to add to the discussion, (what i learned at the conference) this_function() is mostly usefull in hilfe-like situations,
I guess this is the computer science way of defining this_function:
function fac = Y (lambda (function this_function, int x)
{ return (x == 0) ? 1 : x * this_function(x - 1); });
Result: `()
fac(17);
Result: 355687428096000
All you need is to first define this general but strange-looking function:
function Y(function f)
{ return lambda(mixed y) { return (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }) (lambda(function x, mixed w) { return f(lambda(mixed z) { return x(x, z); }, w); }, y); }; }
It took me quite a while to try to remember what the function looks like, and then write it in pike ;-)
/ Niels Möller (igelkottsräddare)