Generator (computer programming): Difference between revisions

Content deleted Content added
for algorithmic correctness p should be initialized to [2]. the loop invariant being -
Line 295:
Infinite Fibonacci sequence:
<syntaxhighlight lang="php">
function fibonacci(): \Generator
{
$last = 0;
Line 314:
Fibonacci sequence with limit:
<syntaxhighlight lang="php">
function fibonacci(int $limit): generatorGenerator
{
yield $a = $b = $i = 1;