Last active
October 14, 2022 14:59
-
-
Save dinocarl/de4e3e52e2f03783831a29957a2cb5e4 to your computer and use it in GitHub Desktop.
A dot operator function with reduce
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 dot = (f, g) => a => f(g(a)); | |
const cmp = reduce(dot, identity); | |
const cmp2 = reduce(o, identity); | |
[ | |
compose( | |
sum, | |
range(2), | |
inc, | |
multiply(4) | |
)(1), | |
cmp([ | |
sum, | |
range(2), | |
inc, | |
multiply(4) | |
])(1), | |
cmp2([ | |
sum, | |
range(2), | |
inc, | |
multiply(4) | |
])(1), | |
dot(dot(dot(sum, range(2)), inc), multiply(4))(1), | |
o(o(o(sum, range(2)), inc), multiply(4))(1), | |
sum(range(2)(inc(multiply(4)(1)))), | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment