Skip to content

Instantly share code, notes, and snippets.

@islamhaqq
Created April 3, 2018 05:24
Show Gist options
  • Save islamhaqq/1f2ddba41c65ddd409130eaf2288a692 to your computer and use it in GitHub Desktop.
Save islamhaqq/1f2ddba41c65ddd409130eaf2288a692 to your computer and use it in GitHub Desktop.
ScalyNoteworthyGzip created by SyedAman - https://repl.it/@SyedAman/ScalyNoteworthyGzip
Function.prototype.curry = function () {
const theOriginalFunctionDefinitionWeAreCurrying = this;
const theFirstGroupOfParameters = arguments;
return function() {
const theSecondGroupOfParameters = arguments;
return theOriginalFunctionDefinitionWeAreCurrying(...theFirstGroupOfParameters, ...theSecondGroupOfParameters);
}
}
function add(x,y) {
return x + y;
}
// unit test
const add1 = add.curry(1);
assert(add1(2) === 3);
const add7 = add.curry(7);
assert(add7(10) === 17);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment