Created
February 4, 2022 09:21
-
-
Save aminnairi/79d960991aa3b22133992e1da42eb866 to your computer and use it in GitHub Desktop.
Partial Application
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
const partial = (callback, ...initialArguments) => { | |
return (...additionalArguments) => { | |
const allArguments = [...initialArguments, ...additionalArguments]; | |
if (allArguments.length >= callback.length) { | |
return callback(...allArguments); | |
} | |
return partial(callback, ...allArguments); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment