- array_map: documentation ( source)
- var_dump: documentation ( source)
<?php
function o($f, $g)
{
return function (...$x) {
return $f(...$g(...$x));
};
}
$f = function ($a, $b) {
return [$a + $b, $a * $b];
};
$g = function (...$n) {
return array_map(function ($n) {
return n ** 2;
}, $n);
};
$h = o($f, $g);
var_dump($h(2, 3));