JuliaLang/julia — Issue #550: Support guards/filters in list comprehensions
Author: pao
Created: 2012-03-09 04:00:32+00:00
State: open

Quoting @rtzui in #547:
On the other hand more powerful:

```
x=[1,2,3,4,510,1,2,3,1,9]
y=[sqrt(a) | a ∈ x, x%2==0]
```

(Discussion from @pao)
There is an open syntactic question. The Haskell syntax (shown above) has guards as boolean expressions separated by commas and interspersed with membership assertions, which works as long as you can tell the difference between an expression evaluating to a boolean and a loop assignment statement. Python uses the keyword "if" to precede each guard. I'm sure there are other approaches as well.