Skip to content

Instantly share code, notes, and snippets.

@mathiasverraes
Created November 25, 2014 08:36
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 mathiasverraes/a1bdcb3b177d1b6501ed to your computer and use it in GitHub Desktop.
Save mathiasverraes/a1bdcb3b177d1b6501ed to your computer and use it in GitHub Desktop.
<?php
require_once __DIR__ . '/../src/Verraes/Lambdalicious/load.php';
// non generic, only deals with functions with arity=2
function curry($f) {
return function($x) use($f) {
return function($y) use($f, $x) {
return $f($x, $y);
};
};
}
$multiplyc = curry(multiply);
$multiplyBy5 = $multiplyc(5);
$final = $multiplyBy5(3);
assert(isequal(
$final, 15
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment