Here’s one attempt that uses Iterators.product:
function myprod(v)
x = [1:n for n in reverse(v)]
return vec([[reverse(p)...] for p in Iterators.product(x...)])
end
It gets complicated because you want to increment the last elements first. Otherwise you could drop the reverse calls.
You could optimize it in various ways: using Iterators.reverse(v) instead of reverse(v), if you could use tuples instead of vectors you wouldn’t need to splat [reverse(p)...], and so on.