Skip to content

Instantly share code, notes, and snippets.

@freekmurze
Created December 17, 2016 20:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freekmurze/8624133911d6b791dc4360e62f9a6f45 to your computer and use it in GitHub Desktop.
Save freekmurze/8624133911d6b791dc4360e62f9a6f45 to your computer and use it in GitHub Desktop.
curry.php
<?php
function curry($f, $argument)
{
return function (...$arguments) use ($f, $argument) {
return $f(...array_merge([$argument], $arguments));
};
}
function add(...$numbers)
{
return array_sum($numbers);
}
$incrementWith5 = curry('add', 5);
echo $incrementWith5(1, 2, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment