Re:Magical, Mystical JavaScript Transducers
by chris_st on Saturday June 29, 2019 @08:17AM
(#20312149)
Downside: Still going over the array multiple times.
[ Parent
| on HN ]
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