casualjavascript / haskell-in-es6

Source for "Haskell in ES6" article series

Home Page:http://casualjavascript.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

currying

sergiivorobei opened this issue · 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 😄