Last active
March 28, 2017 04:39
-
-
Save ericTsiliacos/4fca121590e35674f80e06d18427984d 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 monolith = () => { | |
var mutable = 10; | |
var sum = 0; | |
while (mutable !== 0) { | |
if (mutable % 2 === 0) { | |
sum += mutable; | |
} | |
mutable -= 1; | |
} | |
return sum; | |
} | |
const generateList = n => Array.from(Array(n).keys()) | |
const isEven = n => n % 2 == 0 | |
const filter = f => xs => xs.filter(f) | |
const sum = xs => xs.reduce((acc, val) => acc + val) | |
const compose = (f, g) => x => f(g(x)) | |
const composition = () => compose(sum, filter(isEven))(generateList(11)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment