Skip to content

Conversation

@alexeisavca
Copy link

curryN solution can be simplified

curryN solution can be simplified
@dominhhai
Copy link

Great work!
You are using args for specifying arguments but using n for checking whether the final argument came 1 == n.
I think that changing args to n will make your code more clearly because of n is used to specify arguments.

Something like following:

function curryN(fn, n) {
  // If `n` argument was omitted, use the function .length property.
  if (typeof n !== 'number') n = fn.length

    return function (arg) {
           // Implement rest of function for the final argument
        if (n <= 1) return fn(arg)
        // Otherwise, continue to calling grouped arguments with bind method
        return curryN(fn.bind(null, arg), n - 1)
    }
}

module.exports = curryN

@timoxley
Copy link
Owner

timoxley commented Apr 1, 2015

👍

@timoxley
Copy link
Owner

I've moved the solution to use bind via #69 comments welcome

@timoxley timoxley closed this Apr 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants