-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Closed
Milestone
Description
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.
(From @JeffBezanson)
It's maybe not ideal, but you can accomplish this as:
x=[1,2,3,4,510,1,2,3,1,9]
y=[sqrt(a) | a in x[x%2==0] ]
Metadata
Metadata
Assignees
Labels
No labels