public function test_scenario_tupleMaker($array = [1, 2, 3, 4]) { // Test to see if we can fix array_map through starling to get the key with the value $kvTupple = function ($v, $k) { return [$k, $v]; }; $kvMap = P\curry(3, P\ternary('array_map'))->__invoke($kvTupple); $this->assertEquals(array_map($kvTupple, $array, array_keys($array)), P\S($kvMap, 'array_keys')->__invoke($array)); }
</p> <ul> <?php $keyPairs = P\flip(P\binary('array_walk'))->__invoke(function ($value, $key) { echo "<li>{$key} ⇒ {$value}</li>" . PHP_EOL; }); $keyPairs(testData); ?> </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; ?> —$map(x, y -> [y,x])→ <?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) {