Skip to content

Instantly share code, notes, and snippets.

@poohitan
Last active April 17, 2018 14:56
Show Gist options
  • Save poohitan/aafc9674eebdaaafe772383807e27762 to your computer and use it in GitHub Desktop.
Save poohitan/aafc9674eebdaaafe772383807e27762 to your computer and use it in GitHub Desktop.
const number = (num) => operation => operation ? operation(num) : num;
const zero = number(0);
const one = number(1);
const two = number(2);
const three = number(3);
const four = number(4);
const five = number(5);
const six = number(6);
const seven = number(7);
const eight = number(8);
const nine = number(9);
const plus = (right) => left => left + right;
const minus = (right) => left => left - right;
const times = (right) => left => left * right;
const dividedBy = (right) => left => left / right;
console.log(
seven(times(five())),
one(plus(nine())),
eight(minus(six())),
nine(dividedBy(three()))
); // 35, 10, 2, 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment