Re:Magical, Mystical JavaScript Transducers
by agumonkey on Saturday June 29, 2019 @03:19AM
(#20311268)
The article obfuscates the point. Reducers/transducers are from the FP world. In FP avoiding mutable state is one the main point.
Bonus points:
[ Parent
| on HN ]
Re:Magical, Mystical JavaScript Transducers
by chris_st on Saturday June 29, 2019 @08:17AM
(#20312149)
Downside: Still going over the array multiple times.
You could (usually, but not always) compose the functions you're passing into filter and map and use reduce instead to do both operations in a single pass.
(Edit: This is a big point in the article -- apologies, I hadn't finished reading it yet.)
Re:Magical, Mystical JavaScript Transducers
by agumonkey on Saturday June 29, 2019 @09:03AM
(#20312346)
fair point, in js it will, in other languages that idiom gets deforested into a single pass though