You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, i like your work! Its really cool to learn fp style without reading through dozens lines of code :).
I know you copied the curry function from a gist comment 😄 , i took some time to learn how it works and notices a problem - especially when its used together with reduce
Problem in one sentence: If the curried function is called with too many arguments, it will return a new curried function instead of calling the final function. Also the new curried function will now return again a new curried function for every further attempt. https://github.com/selfrefactor/rambda/blob/master/modules/curry.js#L4
One way to fix it, would be to change o.length === f.length to o.length >= f.length
An alternative would be to change the reduce function in the way, that it only calls with acc and value, (Ramda does it like that: http://ramdajs.com/0.23.0/docs/#reduce)
The text was updated successfully, but these errors were encountered:
The approach to change reduce was just thought as an alternative - rather bad alternative because the callback of builtin map also gets idx and array. There is no bug or so in reduce! Actually I noticed the bug in curry because I was trying around with reduce and a curried function.
In Ramda functions like reduce and map dont provide idx and array to the cb, actually they had a long discussion about this: ramda/ramda#452
In my opinion both ways (with and without idx and array) are perfectly fine, the library author should decide which one is the right ;).
First off, i like your work! Its really cool to learn fp style without reading through dozens lines of code :).
I know you copied the curry function from a gist comment 😄 , i took some time to learn how it works and notices a problem - especially when its used together with reduce
Problem in one sentence: If the curried function is called with too many arguments, it will return a new curried function instead of calling the final function. Also the new curried function will now return again a new curried function for every further attempt.
https://github.com/selfrefactor/rambda/blob/master/modules/curry.js#L4
A basic example (ES6):
Reduce example:
Reduce calls the add function not only with acc and value, but also with index and array
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce
o.length === f.length
too.length >= f.length
The text was updated successfully, but these errors were encountered: