Ejemplo n.º 1
0
 public function test_return()
 {
     $countArgs = function () {
         return func_num_args();
     };
     $this->assertInstanceOf(Closure, P\binary($countArgs), 'binary should return a closure');
     $this->assertEquals(2, P\binary($countArgs)->__invoke(1, 2, 3), 'binary should eat all but two arguments');
 }
Ejemplo n.º 2
0
    </ul>
</section>
<section>
    <h2>Thrill as I convert this Hash Array to an array of Tupples!</h2>
    <p>
        <?php 
$tupleMaker = P\S(P\ternary('array_map')->__invoke(function ($val, $key) {
    return [$key, $val];
}), 'array_keys');
$testDataAsTuple = $tupleMaker(testData);
?>
        <?php 
echo $jsonTestData;
?>
 &mdash;$map(x, y -> [y,x])&rightarrow;
        <?php 
echo json_encode($testDataAsTuple);
?>
    </p>
    <p>And to show why I picked these numbers</p>
    <ul>
        <?php 
P\flip(P\binary('array_walk'))->__invoke(function ($tuple) {
    echo "<li>2<sup>{$tuple['0']}</sup> = {$tuple['1']}</li>" . PHP_EOL;
}, $testDataAsTuple);
?>
    </ul>
</section>
</body>
</html>