Curry
function curry(fn: Function): Function {
return function curried(...args) {
// fn.length = arg length
if (args.length >= fn.length) {
return fn(...args)
}
return (...nextArgs) => curried(...args, ...nextArgs)
};
};