/** * @dataProvider scenarioProvider */ public function test_scenario($arrayLike, $startVal, $action, $expected) { $this->assertEquals($expected, P\fold($action, $startVal, $arrayLike)); }
—map($makeView)→ <?php echo $joinComma($map($makeView, testData)); ?> </p> </section> <section> <h2>Again, but now using fold to produce the join!</h2> <p> <?php echo $jsonTestData; ?> —map($makeView)—fold→ <?php echo P\fold(function ($output, $value) { return $output ? "{$output}, {$value}" : $value; }, '', $map($makeView, testData)); ?> </p> </section> <section> <h2>Again, but now using reduce to produce the join!</h2> <p> <?php echo $jsonTestData; ?> —map($makeView)—reduce→ <?php echo P\reduce(function ($output, $value) { return "{$output}, {$value}"; }, $map($makeView, testData));