D
Size: a a a
D
SN
D
D
SN
D
PM
SN
PM
SN
PM
PM
SN
AP
V
EK
V
V
V
const curryMaker = (pred, reducer, memo = 0) => (...args) => {
const currentRes = reducer(...[memo, ...args]);
return pred(currentRes) ? currentRes : (...nextArgs) => curryMaker(pred, reducer, currentRes)(...nextArgs)
};
const summator = curryMaker((val) => val >= 10, function (memo, ...args) {
return R.sum([memo, ...args]);
});
summator(5)(1)(7);
// => 13
let j = 0;
for (let i = 0, res = null; i < 10000000; i++) {
res = summator(0);
if (typeof res === 'function') {
j++;
}
}
setTimeout(() => console.log('j', j), 1);