2632. Curry
https://leetcode.com/problems/curry
Javascript
var curry = function(fn) {
return function curried(...args) {
if (args.length >= fn.length) {
return fn(...args)
}
return (...additions) => curried(...args, ...additions)
};
};
Typescript
function curry(fn: Function): Function {
return function curried(...args) {
if (args.length >= fn.length) {
return fn(...args)
}
return (...additions) => curried(...args, ...additions)
};
}