Skip to content

Instantly share code, notes, and snippets.

@kingcrunch
Created March 8, 2010 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kingcrunch/325482 to your computer and use it in GitHub Desktop.
Save kingcrunch/325482 to your computer and use it in GitHub Desktop.
<?php
function curry($f, $arg1) {
$args = func_get_args();
array_shift($args);
return function () use ($f, $args) {
$callArgs = func_get_args();
$args = array_merge($args,$callArgs);
return call_user_func_array($f,$args);
};
}
$f = curry('\\substr','Hallo Welt');
echo $f(2,-2) . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment