Ejemplo n.º 1
0
 public function testComplexReductions()
 {
     $this->assertSame(['ab', 'abcd', 'abcdef'], toArrayWithKeys(reductions(function ($acc, $value, $key) {
         return $acc . $key . $value;
     }, ['a' => 'b', 'c' => 'd', 'e' => 'f'], '')));
 }
Ejemplo n.º 2
0
 public function testReductions()
 {
     $this->assertSame([1, 3, 6, 10, 15], toArrayWithKeys(reductions(fn\operator('+'), range(1, 5), 0)));
     $this->assertSame([1, 2, 6, 24, 120], toArrayWithKeys(reductions(fn\operator('*'), range(1, 5), 1)));
 }