3 ms·
> I wouldn't compare a comprehension to a loop because a loop doesn't typically have an output. Loops in lots of languages have outputs. It's kind of necessary
by dragonwriter 8y ago
> I wouldn't compare a comprehension to a loop because a loop doesn't typically have an output.
Loops in lots of languages have outputs. It's kind of necessary in expression-oriented languages.
But it's true that comprehensions are different than Python loops in that way (and are, in fact, equivalent to maps with joins and filters, like an SQL SELECT statement.)
- afandian 8y agoPer my other reply [0] maybe my definition of loop, based on C, was too narrow. I draw a distinction with map, recursion, lazy sequences etc [0] https://news.ycombinator.com/item?id=19591233 https://news.ycombinator.com/item?id=19591233