Skip to content

Instantly share code, notes, and snippets.

@weskerfoot
Created July 22, 2013 20:03
Show Gist options
  • Save weskerfoot/6057151 to your computer and use it in GitHub Desktop.
Save weskerfoot/6057151 to your computer and use it in GitHub Desktop.
<?php
function compose($f, $g) {
return function() use($f, $g) {
$args = func_get_args();
return $f(call_user_func_array($g, $args));
};
}
function add1($a) {
return $a + 1;
}
function mult($a, $b) {
return $a * $b;
}
$foo = compose("add1", "mult");
echo $foo(1,2), "\n";
echo $foo(2,3);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment