コード例 #1
0
 public function testTimes()
 {
     $fib = function ($n) {
         // http://stackoverflow.com/a/27190248/49146
         return (int) round(pow((sqrt(5) + 1) / 2, $n) / sqrt(5));
     };
     $expected = [0, 1, 1, 2, 3, 5, 8, 13];
     $this->assertSame($expected, Underscore::times(8, $fib)->toArray());
 }
コード例 #2
0
function _times($n, $iterator, $context = NULL)
{
    return Underscore::times($n, $iterator, $context);
}
コード例 #3
0
ファイル: Underscore.php プロジェクト: brombal/underscore.php
 /**
  * @tags utilities
  */
 public function testTimes()
 {
     $fn = function () {
         static $num = 0;
         return ++$num;
     };
     $this->array(_::times(3, $fn))->isEqualTo([1, 2, 3]);
 }