If this is something you do often, you could create a custom iterator that 
would allow you to do

l = [(i,j) for (i,j) in DiagonalIterator(1:4, i -> i+1:4)]

This would require defining a type DiagonalIterator with a constructor with 
that signature, as well as methods for start, next, done and length on that 
type, but it should by no means have to be difficult.

// T

On Sunday, April 3, 2016 at 10:36:24 PM UTC+2, Erik Schnetter wrote:

Nothing has been set in stone, but one proposed syntax is 
>
> ```Julia 
> l = collect((i, j) for j in range(i+1, 5) for i in range(1, 5)) 
> ``` 
>
> i.e. using parentheses instead of brackets, exchanging the order of 
> `i` and `j`, and using an explicit call to `collect` to convert the 
> generator into an array. Without that call, you get a generator that 
> is more efficient since it doesn't have to allocate memory -- compare 
> `range` and `xrange` in Python 2. In most circumstances, you would be 
> able to use the generator directly instead of having to convert it to 
> an array, and then you don't need the call to `collect. 
>
> -erik 
>
>
>
> On Sun, Apr 3, 2016 at 1:25 PM, Jonatan Pallesen <[email protected] 
> <javascript:>> wrote: 
> > Performance is not the main factor. More importantly I don't think the 
> vcat 
> > solution looks very neat. I'm curious about what the proposed generator 
> > syntax is. 
>
>
>
> -- 
> Erik Schnetter <[email protected] <javascript:>> 
> http://www.perimeterinstitute.ca/personal/eschnetter/ 
>
​

Reply via email to