public function testMappingAndFirst()
 {
     $transformed = Fp\transduce(Fp\compose(Fp\mapping(square_makker()), Fp\first(function ($x) {
         return $x > 6;
     })), Fp\single_result(), range(1, 6));
     $this->assertEquals(9, $transformed);
 }
Esempio n. 2
0
 public function testComposabilityWithHimself()
 {
     $composed = Fp\compose(plus_one_makker(), plus_one_makker(), Fp\compose(plus_one_makker(), square_makker()));
     $this->assertEquals(12, $composed(3));
 }
Esempio n. 3
0
 public function testCompositionWithMapFilterWithArityOfOne()
 {
     $transduced = Fp\transduce(Fp\compose(Fp\map(square_makker()), Fp\filter(is_even_makker())), Fp\appending(), [1, 2, 3, 4, 5, 6]);
     $this->assertEquals([4, 16, 36], $transduced);
 }
Esempio n. 4
0
 public function testTransducing()
 {
     $transduced = $this->collection->transduce(Fp\compose(Fp\map(square_makker()), Fp\filter(is_even_makker())), Fp\appending())->values();
     $this->assertEquals([4, 16], $transduced);
 }