je suis trop génial 
mwahahaaa
let curryed = (func) => {
const currying = (acc, ...args) => {
if (acc.length + args.length >= func.length)
return func(...acc, ...args);
else
return context(...acc, ...args);
}
const context = (...acc) => {
return (...args) => {
if (args.length >= 1 && acc.length + args.length <= func.length)
return currying(acc, ...args);
else
return undefined;
}
}
return context();
}
let add = curryed((a, b) => a + b);
let add5 = add(5);
console.log(add5(5) == 10, add5(5) == add(5, 5));
console.log(add5(3) == 8, add5(3) == add(5, 3));
function sayHello(firstname, lastname) {
console.log(`Hello ${firstname} ${lastname}`);
}
let sayHelloJesus = sayHello("Jesus"); // woops, Hello Jesus undefined
let sayHelloCurryed = curryed(sayHello);
let sayHelloChancla = sayHelloCurryed("Chancla"); // not enough argument to be called :P
sayHelloChancla("Goudja"); // Hello Chancla Goudja
sayHelloChancla("Banardor"); // Hello Chancla Banardor
FP


mwahahaaa
let curryed = (func) => {
const currying = (acc, ...args) => {
if (acc.length + args.length >= func.length)
return func(...acc, ...args);
else
return context(...acc, ...args);
}
const context = (...acc) => {
return (...args) => {
if (args.length >= 1 && acc.length + args.length <= func.length)
return currying(acc, ...args);
else
return undefined;
}
}
return context();
}
let add = curryed((a, b) => a + b);
let add5 = add(5);
console.log(add5(5) == 10, add5(5) == add(5, 5));
console.log(add5(3) == 8, add5(3) == add(5, 3));
function sayHello(firstname, lastname) {
console.log(`Hello ${firstname} ${lastname}`);
}
let sayHelloJesus = sayHello("Jesus"); // woops, Hello Jesus undefined
let sayHelloCurryed = curryed(sayHello);
let sayHelloChancla = sayHelloCurryed("Chancla"); // not enough argument to be called :P
sayHelloChancla("Goudja"); // Hello Chancla Goudja
sayHelloChancla("Banardor"); // Hello Chancla Banardor
FP

