zlacker

[parent] [thread] 3 comments
1. tuetuo+(OP)[view] [source] 2025-08-22 15:29:09
Depending on your iterator implementation (or, lackthere of), the functional boils down to your first example.

For example, Rust iterators are lazily evaluated with early-exits (when filtering data), thus it's your first form but as optimized as possible. OTOH python's map/filter/etc may very well return a full list each time, like with your intermediate. [EDIT] python returns generators, so it's sane.

I would say that any sane language allowing functional-style data manipulation will have them as fast as manual for-loops. (that's why Rust bugs you with .iter()/.collect())

replies(2): >>Capric+W >>maleld+K3
2. Capric+W[view] [source] 2025-08-22 15:34:25
>>tuetuo+(OP)
Clojure transducers as well.
3. maleld+K3[view] [source] 2025-08-22 15:49:07
>>tuetuo+(OP)
Python map/filter/zip/etc. return generators, so they're lazily evaluated.
replies(1): >>tuetuo+Jk
◧◩
4. tuetuo+Jk[view] [source] [discussion] 2025-08-22 17:15:36
>>maleld+K3
Thanks, I was not sure, hence the "may". Comment edited :)
[go to top]