Created
March 16, 2018 21:43
-
-
Save dinocarl/de5c8a1a9c732a87bbd5df4aa2ef3b5a to your computer and use it in GitHub Desktop.
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
// can run in the ramda REPL http://ramdajs.com/repl/ | |
const double = (x) => R.add(x, x) | |
const clonewithbase = (base) => R.compose( | |
R.concat([base]), | |
R.clone | |
); | |
const applyFnsToList = (baseCase) => (fn1) => (fn2) => (arr) => { | |
let firstpass = R.map(fn1, arr) | |
let secondpass = clonewithbase(baseCase)(firstpass) | |
let together = R.zip(firstpass, secondpass) | |
return R.map(R.reduce(fn2, baseCase), together) | |
} | |
applyFnsToList(0)(double)(R.add)([1,2,3,4,5]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment