2 ms·
Thanks, I stand corrected. My high level memory is that the map->filter->reduce idiom was broken because <arbitrary>. Adding to my confusion was my conflating t
by brudgers 9y ago
Thanks, I stand corrected. My high level memory is that the map->filter->reduce idiom was broken because <arbitrary>. Adding to my confusion was my conflating that <arbitary> with my memory of map breaking code by returning a map object rather than a list.
- kevinmgranger 9y agoYou're right in that map returned a list in python 2, but in python 3, it returns an iterator. Anyone who relied on indexing or non-lazy behavior would have their code break. GVR doesn't like functional-style programming, so he much prefers the iterative but compact comprehension alternatives. It may just be the circles I hang out in, but most folks aren't map/filter versus comprehension purists. I'll do comprehensions usually, but map/filter when it helps make the line shorter or more readable.
- brudgers 9y agoI don't have anything against list comprehensions. Sometimes they are a very useful abstraction. Other times map->filter->reduce better expresses the business logic of the program (e.g. when the analog is signal processing [1] or Unix pipes). My issue with 'Pythonic' is that it is used to express the idea that someone's thoughts are or are not properly structured. [1]: https://mitpress.mit.edu/sicp/full-text/sicp/book/node35.html https://mitpress.mit.edu/sicp/full-text/sicp/book/node35.htm...