Skip to content

Instantly share code, notes, and snippets.

@ericTsiliacos
Last active March 28, 2017 04:39
Show Gist options
  • Save ericTsiliacos/4fca121590e35674f80e06d18427984d to your computer and use it in GitHub Desktop.
Save ericTsiliacos/4fca121590e35674f80e06d18427984d to your computer and use it in GitHub Desktop.
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