Created
January 4, 2018 14:29
-
-
Save johnrees/284dfe6de5b0cd162078dfb8045adf69 to your computer and use it in GitHub Desktop.
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 inc = (x) => x + 1 | |
const dbl = (x) => x * 2 | |
const add = (x, y) => x + y | |
const multiply = (x, y) => x * y | |
const subtract = (x, y) => x - y | |
const divide = (x, y) => x / y | |
const partial = (fn, ...args) => fn.bind(null, ...args) | |
const _pipe = (f, g) => (...args) => g(f(...args)) | |
const pipe = (...fns) => fns.reduce(_pipe) | |
const pipeline = pipe(add, inc, dbl, inc) | |
console.log(pipeline(1, 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment