Skip to content

Commit

Permalink
Time: 77 ms (26.50%), Space: 48 MB (62.04%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
harmeetsingh11 committed May 14, 2023
1 parent ae1bde9 commit c783706
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions 2632-curry/2632-curry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @param {Function} fn
* @return {Function}
*/
var curry = function (fn) {
return function curried(...args) {
if (fn.length === args.length) {
return fn(...args);
} else {
return function (...newArgs) {
return curried(...args, ...newArgs);
};
}
};
};

/**
* function sum(a, b) { return a + b; }
* const csum = curry(sum);
* csum(1)(2) // 3
*/

0 comments on commit c783706

Please sign in to comment.