php PHP only function curry args func_get_args args unset args return

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<?php
// PHP 5.3 only
function curry(){
$args = func_get_args();
$f = $args[0];
unset($args[0]);
return function() use($f, $args) {$a = func_get_args(); return call_user_func_array($f, $args+$a); };
}
$mass_log = curry('array_map', 'log');
print_r($mass_log(array(2, 3, 5, 7)));
?>