Skip to content

Instantly share code, notes, and snippets.

@alkhe
Created July 20, 2015 23:37
Show Gist options
  • Save alkhe/af86d57fcadd21f9e587 to your computer and use it in GitHub Desktop.
Save alkhe/af86d57fcadd21f9e587 to your computer and use it in GitHub Desktop.
Simple function currying.
let curry = fn => {
let total = fn.length;
let len = 0;
let argarr = [];
let recur = (...args) => {
len += args.length;
argarr = argarr.concat(args);
return len >= total ? fn(...argarr) : recur;
}
return recur;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment