Exemplo n.º 1
0
 public function test_combinatoin_2()
 {
     $arr = array(1, 2, 3, 4);
     Enumerator::combination_($arr, 1, function ($key, &$value) {
         if ($value[0] == 3) {
             throw new ContinueException();
         }
         $value[0]++;
     });
     $this->assertEquals(array(array(2), array(3), array(3), array(5)), $arr);
 }
Exemplo n.º 2
0
 public function test_combinatoin_4()
 {
     // tests destructive
     $arr = array(1, 2, 3, 4);
     Enumerator::combination_($arr, 4, function ($key, &$value) {
         foreach ($value as &$v) {
             $v++;
         }
     });
     $this->assertEquals(array(array(2, 3, 4, 5)), $arr);
 }