Created
June 12, 2017 15:45
-
-
Save jboxman/4a1fdd9482232b6fce097a437b9a47ac to your computer and use it in GitHub Desktop.
Exercise from Kyle Simpson's Functional-Lite programming course
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
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