-
Notifications
You must be signed in to change notification settings - Fork 0
curryRight
Subhajit Sahu edited this page Jul 29, 2022
·
2 revisions
Generate right-curried version of a function.
Alternatives: curry, curryRight.
function curryRight(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.curryRight(sub);
fn(2)(3); // sub(3, 2)
// → 1
var array = [1];
var push2 = (x: number, y: number) => array.push(x, y);
var fn = xfunction.curryRight(push2, 2);
fn(2)(3); // push2(3, 2)
array;
// → [1, 3, 2]