Files
30-seconds-of-code/snippets/curry.md
2017-12-10 17:59:07 +02:00

12 lines
332 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
var curry = f =>
(...args) =>
args.length >= f.length ? f(...args) : (...otherArgs) => curry(f)(...args, ...otherArgs)
```