Is there a name for an iterator that is like `product(a, a)` except only distinct-indexed elements are paired

I think IterTools.subsets will do what you’re looking for. Something like:

for (i,j) in IterTools.subsets(1:length(a), Val{2}())
    # do something
end

This essentially returns the indices of an upper triangular matrix.

8 Likes