Skip to content

Instantly share code, notes, and snippets.

@B1Z0N
Created December 4, 2019 05:44
Show Gist options
  • Save B1Z0N/0cc87b5ed84926e7c4c2948a3f7c4ec4 to your computer and use it in GitHub Desktop.
Save B1Z0N/0cc87b5ed84926e7c4c2948a3f7c4ec4 to your computer and use it in GitHub Desktop.
Some functional concepts implemented in js
'use strict';
const curry = (f) => {
const argc = f.length;
if (argc === 1) {
return f;
}
return (a) => curry(f.bind(null, a), argc - 1);
};
const add3 = (a, b, c) => {
return a + b - c;
};
const add3Curried = curry(add3);
const result = add3Curried(1)(2)(5);
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment