2 ms·
The first thing you show is a list comprehension [1], and it's still very much functional style, even if it has a "for" in it. Heck, Haskell has pure list comp
by rhaps0dy 11y ago
The first thing you show is a list comprehension [1], and it's still very much functional style, even if it has a "for" in it.
Heck, Haskell has pure list comprehensions. [2]
[1] https://en.wikipedia.org/wiki/List_comprehension#Python https://en.wikipedia.org/wiki/List_comprehension#Python
[2] https://en.wikipedia.org/wiki/List_comprehension#Haskell https://en.wikipedia.org/wiki/List_comprehension#Haskell
- Retra 11y agoOh, I agree. I mentioned it because is the preferred style in Python -- probably because it is so readable. But my points still apply to the loop version.