Oh, you are right, it should be func and not fn. Thank you, I updated the code.
You know what, I actually have an issue with that. If I remove nextFunc from the arguments, I have an TypeError when I call my curried function.
But, when I implement my same curried function using the function keyword :
function curried(func,arity = func.length) { return (function nextCurried(prevArgs){ return function curried(nextArg){ let args = prevArgs.concat( [nextArg] ); if (args.length >= arity) { return func( ...args ); } else { return nextCurried( args ); } }; })( [] ) }
I don't need to specify this third argument. My guess is ( and it's only a guess so far ) that the arrow functions somehow changes something in my implementation. I'll dig a bit more. Good question!
And don't forget to also change the default value of arity from fn.length to func.length :)
arity
fn.length
func.length
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Oh, you are right, it should be func and not fn. Thank you, I updated the code.
You know what, I actually have an issue with that. If I remove nextFunc from the arguments, I have an TypeError when I call my curried function.
But, when I implement my same curried function using the function keyword :
I don't need to specify this third argument. My guess is ( and it's only a guess so far ) that the arrow functions somehow changes something in my implementation. I'll dig a bit more. Good question!
And don't forget to also change the default value of
arity
fromfn.length
tofunc.length
:)