Created
February 15, 2020 20:35
-
-
Save zonuexe/071c4988171d8114a0d45990e9562261 to your computer and use it in GitHub Desktop.
ジェネレータで無限を手玉に取る修行
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function fib(int $i) | |
{ | |
return [0, 1][$i] ?? fib($i - 1) + fib($i - 2); | |
} | |
var_dump(iterator_to_array(map(Closure::fromCallable('fib'), xrange(1, 24)))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment