Created
February 17, 2022 04:25
-
-
Save r17x/026abb2e2a0dbfa8250225d4b0d29a49 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 add = (a, b) => a + b | |
const adds = (...n) => n.reduce(add) | |
const mul = (a, b) => a * b | |
const muls = (...n) => n.reduce(mul) | |
const div = (a, b) => a / b | |
const divs = (...n) => n.reduce(div) | |
const mod = (a, b) => a % b | |
const mods = (...n) => n.reduce(mod) | |
const app = (f, n) => f(n) | |
const appFlip = (n, f) => app(f, n) | |
const flow = (...fns) => n => fns.reduce(appFlip, n) | |
const pipe = (n, ...fns) => flow(fns)(n) | |
const toInt = n => n | 0 | |
const mul10 = (a) => mul(a, 10) | |
const mod10 = (a) => mod(a, 10) | |
const div10 = (a) => div(a, 10) | |
// (a * 10) + b | |
const mulWithAdd = (a, b) => pipe(a, mul10, a_ => add(a_, b)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment