Skip to content

Instantly share code, notes, and snippets.

@jboxman
Created June 12, 2017 15:45
Show Gist options
  • Save jboxman/4a1fdd9482232b6fce097a437b9a47ac to your computer and use it in GitHub Desktop.
Save jboxman/4a1fdd9482232b6fce097a437b9a47ac to your computer and use it in GitHub Desktop.
Exercise from Kyle Simpson's Functional-Lite programming course
function addnMapReduce(...args) {
// Can do args.slice(1).reduce(..., args[0]) to skip num(0) no-op
return args.reduce((prev, cur) => () => add2(prev, cur), num(0))();
}
function num(number) {
return () => number;
}
function add2(fn1, fn2) {
return add(fn1(), fn2());
}
function add(a, b) {
return a + b;
}
function num1() {
return 10;
}
function num2() {
return 7;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment