>
> I just realized that combinations is in base Julia, so it can instead be
>
collect(combinations(collect(1:4), 2))
>
> I thought of another approach
>
using Iterators
collect(subsets(collect(1:4), 2))
>
>
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.
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