Skip to content

Instantly share code, notes, and snippets.

@oliverturner
Created January 20, 2018 14:37
Show Gist options
  • Save oliverturner/2798672d2bc453f1cb827c30b592ed44 to your computer and use it in GitHub Desktop.
Save oliverturner/2798672d2bc453f1cb827c30b592ed44 to your computer and use it in GitHub Desktop.
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