Skip to content
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

Supporting dependent loop ranges in comprehensions #15384

Closed
KristofferC opened this issue Mar 7, 2016 · 3 comments
Closed

Supporting dependent loop ranges in comprehensions #15384

KristofferC opened this issue Mar 7, 2016 · 3 comments

Comments

@KristofferC
Copy link
Member

Simple example,

this works:

for i in 1:3, j in 1:i
    println(i + j)
end

this fails with UndefVarError on i.

[i+j for i in 1:3, j in 1:i]

Would it be possible to support the syntax of the second version?

@nalimilan
Copy link
Member

I don't see how it could work given that it wouldn't return a standard (rectangular) array. Would you expect it to return a triangular matrix? But then there is no general solution for arbitrary expressions of j.

@KristofferC
Copy link
Member Author

I forgot that comprehensions don't just return a one dimensional array. What I wanted would just be the expression in a straight list, like [2,3,4,4,5,6]

@JeffBezanson
Copy link
Member

Dup of #4867

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants