casualjavascript/haskell-in-es6

currying

sergiivorobei opened this issue · 1 comments

Hello guys! Really enjoy what you are doing.

In Haskell every function is curried. Probably you should transform existing functions to support currying? (And in es6 it looks nice))

My implementation is:

function curry(fn, ...initialArgs) {
    const curried = (...args) => {
        if (args.length >= fn.length) {
            return fn(...args);   
        }
        return (...moreArgs) => curried(...[...args, ...moreArgs]);
    }
    return curried(...initialArgs);
};

@kennyx46 looks really neat!! I think I am going to reuse your code... Thanks a lot 😄