Skip to content

Commit 74c5bbf

Browse files
authored
Update generalized-curry.js
1 parent 30bb70a commit 74c5bbf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

generalized-curry.js

+17
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,20 @@ const curry = (fn) => {
1111
return nest([]);
1212
}
1313

14+
15+
/*
16+
Alternate Solution
17+
const curry = (fn) => {
18+
return (...ags) => {
19+
if (ags.length === 0) {
20+
throw Error('No Arguments Supplied');
21+
}
22+
if (ags.length >= fn.length) {
23+
return fn(...ags);
24+
}
25+
return curry(fn.bind(null, ...ags));
26+
};
27+
}
28+
Why does this work?
29+
https://stackoverflow.com/questions/50616087/generalised-curry-javascript
30+
*/

0 commit comments

Comments
 (0)