- Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.15
- Parse error: syntax error, unexpected '}' in /in/Amb0B on line 17
Process exited with code 255.
<?php
function compose(/* funs to compose */) {
$fl = func_get_args();
return function($x) use($fl) {
$val = $x;
while (null !== $f = array_pop($fl)) {
$val = $f($val);
};
return $val;
};
}
$up = function($s) {return strtoupper($s);};
$y = function($s) {return $s.'!';};
$reverse = function($a) {return array_reverse($a);};
$head = function($a) {return array_shift(array_values($a))};
$data = ['jumpkick', 'roundhouse', 'uppercut'];
$c = compose($y, $up, $head, $reverse);
var_dump($c($data));