Created
January 20, 2018 14:37
-
-
Save oliverturner/2798672d2bc453f1cb827c30b592ed44 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
export const fmap = f => g => x => f(g(x)); | |
export const curryOnce = f => x => (...args) => f(x, ...args); | |
export const curry = n => f => (n == 1 ? f : fmap(curry(n - 1))(curryOnce(f))); | |
export const method = m => m.call.bind(m); | |
export const methodWithArgs = n => m => curry(n)(method(m)); | |
export const flip = f => x => y => f(y)(x); | |
export const split = methodWithArgs(2)("".split); | |
export const map = flip(methodWithArgs(2)([].map)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment