> function Y($F) {
> $func = function ($f) { return $f($f); };
> return $func(function ($f) use($F) {
> return $F(function ($x) use($f) {
> $ff = $f($f);
> return $ff($x);
> });
> });
> }
That's interesting;
> First, we define $foo and load it with NULL so that it is available for
> referencing.
It turns out loading $foo is superfluous; I can get away with just:
$foo = function($foo) use (&$foo) {
$foo();
}
> Next, in terms of program logic, we create a closure with a lexical
> ('use') va
Quoth Justin Martin on Pungenday, the 30th of Discord:
> Apparently it works as such:
>
> $foo = NULL;
> $foo = function($foo) use (&$foo) {
> ...
> }
>
> Still rather hackish, but better than globals I suppose?
Heh; amazing. I'm not going to pretend to comprehend this hack; but
I'll use i
Quoth Justin Martin on Pungenday, the 30th of Discord:
> If I recall correctly, you can use the 'use' keyword.
Thanks, Justin; that occurred to me, too. But the following results in
"Notice: Undefined variable: factorial":
$factorial = function($n) use ($factorial) {
if ($n == 1)
The original anonymous functions patch[1] contained support for
__FUNCTION__ as a recursion mechanism in closures, such that I should
be able to do something like this:
$factorial = function($n) {
if ($n == 1)
return 1;
else
return $n * call_user_func(__FUNCTION__, $n