Created
January 19, 2019 05:06
-
-
Save abiodun0/6d6abd6baba0263e3cb92d2f9283790c to your computer and use it in GitHub Desktop.
some neat tricks
This file contains hidden or 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 uncurry = fn => (...args) => args.reduce((acc, arg) => acc(arg), fn) | |
const add = x => y => x + y | |
const sum = xs => xs.reduce((x, y) => uncurry(add)(x, y)) | |
sum([1, 2, 3]) | |
// -> 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment