Skip to content
Subhajit Sahu edited this page Jul 29, 2022 · 3 revisions

Generate curried version of a function.

Alternatives: curry, curryRight.


function curry(x, n)
// x: a function
// n: number of parameters [all]
const xfunction = require('extra-function');


var sub = (x: number, y: number) => x - y;
var fn  = xfunction.curry(sub);
fn(2)(3);  // sub(2, 3)
// → -1

var fn  = xfunction.curry(Math.min, 3);
fn(5)(8)(3);  // Math.min(5, 8, 3)
// → 3


References

Clone this wiki locally