> > > I could use an array, but one product can correspond to different number > of bases. > > That's why I decided to use tuples. > > You could use an Array of (different length) Arrays, similar to Array of Tuples.
Another strategy might be to construct a vector of (Product, Base) pairs, and then iterate over this vector: product_bases = Tuple{ProductType, BaseType}[] for k in Products, b in Bases if accordance[k,b] push!(product_bases, (k,b)) end end for (k,b) in product_bases ... end