Skip to content

Commit 65a1569

Browse files
authored
Update functions.mdx
made the partial execution/currying easy
1 parent 261af5c commit 65a1569

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

web/src/pages/challenges/functions.mdx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,13 @@ function multiply(num1) {
165165
- The arguments can be 1 or multiple, and the actual function will be called once the count of expected arguments are reached
166166

167167
```js copy
168-
function curryFunc(fn) {
169-
return function curry(...args) {
170-
if (fn.length <= args.length) {
171-
return fn.apply(this, args);
172-
} else {
173-
return function (...args2) {
174-
return curry.apply(this, args.concat(args2));
175-
};
168+
function curryFunc(func) {
169+
return function curry(...ip) {
170+
if(ip.length < func.length) {
171+
return curry.bind(this, ...ip);
172+
}
173+
return func(...ip);
176174
}
177-
};
178175
}
179176

180177
// driver code

0 commit comments

Comments
 (0)