Skip to content

Instantly share code, notes, and snippets.

@dinocarl
Created March 16, 2018 21:43
Show Gist options
  • Save dinocarl/de5c8a1a9c732a87bbd5df4aa2ef3b5a to your computer and use it in GitHub Desktop.
Save dinocarl/de5c8a1a9c732a87bbd5df4aa2ef3b5a to your computer and use it in GitHub Desktop.
// 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