Created
April 3, 2018 05:24
-
-
Save islamhaqq/1f2ddba41c65ddd409130eaf2288a692 to your computer and use it in GitHub Desktop.
ScalyNoteworthyGzip created by SyedAman - https://repl.it/@SyedAman/ScalyNoteworthyGzip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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