3 ms·
Python's list comprehensions are close to set notation in math. Here's Python: [2*x for x in range(n + 1) if x <= 100] Here's set notation: {2*x | x
by wenc 2y ago
Python's list comprehensions are close to set notation in math. Here's Python:
[2*x for x in range(n + 1) if x <= 100]
Here's set notation:
{2*x | x in 0..n, x <= 100}
So it reads pretty easily for those of us used to set notation. Haskell is even more similar to set notation:
[2*x | x <- [0..n], x <= 100]