Last active
January 3, 2019 04:35
-
-
Save nathan-lapinski/0e0b2ecff5f2e00bdeabaaaa00d049a9 to your computer and use it in GitHub Desktop.
pipe example
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 pipe = (...fns) => initialVal => fns.reduce((g,f) => f(g), initialVal); | |
const add1 = x => x + 1; | |
const mul2 = x => x * 2; | |
const res = pipe(add1,mul2)(0); // mul2(add1(0)) === 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment