getify / Functional-Light-JS

Pragmatic, balanced FP in JavaScript. @FLJSBook on twitter.
http://FLJSBook.com
Other
16.6k stars 1.96k forks source link

ch4: fixing compose implementation bug #147

Closed darkamenosa closed 6 years ago

darkamenosa commented 6 years ago

This commit fixes #146

getify commented 6 years ago

Thanks for finding and fixing this bug.

However, rather than fixing this with slice(), I'd rather fix it by saying [...fns].reverse().reduce(..) (still all on one line, for layout reasons). And btw, this code is repeated/quoted in chapter 9, so it needs to be fixed there, too. :)

Also, in chapter 9, about a page after that reference, fns.reverse().reduce(..) is quoted again, in a paragraph, so that should be updated, as well.

darkamenosa commented 6 years ago

I have changed the implementation follow your recommendation and updated chapter 9. Thanks for reminding me.

DScheglov commented 6 years ago

Hi, I guess if we are using spread to splice the array, so we could use the reduceRight to avoid reverse and slice at all, am I wrong? :)

@getify, thanks a lot for the Book.

getify commented 6 years ago

@DScheglov this is intentionally not done here because we come back to the topic of compose(..) in ch9 when we talk about list operations, and we illustrate reduceRight(..) there.

getify commented 6 years ago

Thanks so much!