Content deleted Content added
Scorchgeek (talk | contribs) →In PowerShell: the use of $script: does not appear intended -- it would make $a and $b share state and is unnecessary with the use of .GetNewClosure() |
m →In PHP: PHP-FIG PSR |
||
Line 572:
<source lang=PHP>
function Accumulator(
$current = $start;
return function(
return $current += $x;
};
}
</source>
Line 585:
$a = Accumulator(4);
$x = $a(5);
echo "x = $x<br/>"; // x = 9
$x = $a(2);
echo "x = $x<br/>"; // x = 11
</source>
|