|
|
|
|
|
by thomasahle
3742 days ago
|
|
The comprehension approach, while requiring more syntax, seems to often produce a more 'natural' order of operations. For example, compare [p for p in range(2,100) if all(p%q!=0 for q in range(2,p))]
with range(2,100).filter(p => range(2,p).map(q => p%q!=0).all())
It might be a small thing, but in the first one I feel the prime 'p' becomes the center piece, whereas in the second, 'p' is burrowed somewhat in the expression. |
|