Download src/php/php-src/Zend/tests/generators/fibonacci.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 413 Bytes
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/generators/fibonacci.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/Zend/tests/generators/fibonacci.phpt
-
curl -L -o fibonacci.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/generators/fibonacci.phpt
413 Bytes
| --TEST-- | |
| Creating an infinite fibonacci list using a generator | |
| --FILE-- | |
| function fib() { | |
| list($a, $b) = [1, 1]; | |
| while (true) { | |
| yield $b; | |
| list($a, $b) = [$b, $a + $b]; | |
| } | |
| } | |
| foreach (fib() as $n) { | |
| if ($n > 1000) break; | |
| var_dump($n); | |
| } | |
| --EXPECT-- | |
| int(1) | |
| int(2) | |
| int(3) | |
| int(5) | |
| int(8) | |
| int(13) | |
| int(21) | |
| int(34) | |
| int(55) | |
| int(89) | |
| int(144) | |
| int(233) | |
| int(377) | |
| int(610) | |
| int(987) | |