Skip to content

currying #9

@sergiivorobei

Description

@sergiivorobei

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);
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions