Example #1
0
 /**
  * @dataProvider scenarioProvider
  */
 public function test_scenario($arrayLike, $startVal, $action, $expected)
 {
     $this->assertEquals($expected, P\fold($action, $startVal, $arrayLike));
 }
Example #2
0
 —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;
?>
 &mdash;map($makeView)&mdash;fold&rightarrow;
        <?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;
?>
 &mdash;map($makeView)&mdash;reduce&rightarrow;
        <?php 
echo P\reduce(function ($output, $value) {
    return "{$output}, {$value}";
}, $map($makeView, testData));