-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple generators in list comprehensions #2640
Comments
Discussed multiple times already #2030 |
Ah the language I used was a bit different, so I couldn't find it. Thanks. Closing for now. |
That's my job ;) |
FWIW, I'd prefer to switch to the proposed semantics. |
Yes -- I think it's worth talking about (over in #2030), especially if we can have our cake and eat it too -- have a way of allowing the inner comprehension to either be treated as an expression, or flattened out. |
I was writing a Haskell tutorial for my students today. They were to write a function that returns all the possible sums of two lists:
So I thought: let's try that in coffee:
which produces this beast of js:
As you can see this will produce an array of arrays rather then a single array. Another problem comes when you wish to use guards:
This will not work, as a is not in scope yet.
My proposal is to change the semantics to allow guard expressions at the end of the list comprehension to be evaluated in the inmost loop.
Also the loop should be compiled rather to this:
The text was updated successfully, but these errors were encountered: