[julia-users] Re: List comprehension for 1 <= i < j <= 4

2016-04-05 Thread Jonatan Pallesen
> > I just realized that combinations is in base Julia, so it can instead be > collect(combinations(collect(1:4), 2))

[julia-users] Re: List comprehension for 1 <= i < j <= 4

2016-04-05 Thread Jonatan Pallesen
> > I thought of another approach > using Iterators collect(subsets(collect(1:4), 2)) > >

Re: [julia-users] List comprehension for 1 <= i < j <= 4

2016-04-03 Thread Jonatan Pallesen
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.

[julia-users] List comprehension for 1 <= i < j <= 4

2016-04-03 Thread Jonatan Pallesen
I want to make a list comprehension for 1 <= i < j <= 4. It can be done with a for loop like this: l = [] for i in 1:4, j in i+1:4 push!(l, (i,j)) end In python a list comprehension can be made like this l = [(i, j) for i in range(1, 5) for j in range(i+1, 5)] But this Julia code gives an