13 lines
369 B
Markdown
13 lines
369 B
Markdown
### Curry
|
|
|
|
Use recursion.
|
|
If the number of provided arguments (`args`) is sufficient, call the passed function `f`.
|
|
Otherwise return a curried function `f` that expects the rest of the arguments.
|
|
|
|
```js
|
|
const curry = f =>
|
|
(...args) =>
|
|
args.length >= f.length ? f(...args) : (...otherArgs) => curry(f)(...args, ...otherArgs);
|
|
// curry(Math.pow)(2)(10) -> 1024
|
|
```
|