I need a function similar to
expand.grid in R, which takes a set of vectors and returns their Cartesian product.
Is there existing art? My first cut is
function expandgrid(vecs) expd =  # vector of expanded vectors inner, outer = 1, prod(length, vecs) for v in vecs lv = length(v) outer ÷= lv push!(expd, repeat(v, inner=inner, outer=outer)) inner *= lv end expd end
although I’m not sure that
expandgrid is the best name in Julia.
Can someone suggest a better name and/or function implementation?