This question already has an answer here:
I am dealing with Tuples of n lists each having potentially different length:
longList = Tuples[list1, list2, ..., listn]:
Since I have to iterate over the elements of longList, precomputing of longList becomes a memory issue very quickly. That's why I'm looking for a lazy list implementation where I can access the ith element of longList without precomputing the whole list.
I came across this piece of code which does almost exactly what I want: Lazy lists of Tuples and Subsets
Unfortunately, it seems to only work with Tuples made from a common list, i.e. tuples taking the form:
I wonder wheter there is a way to either adjust the linked code or whether anyone is aware of a solution to this type of problem.
Thank you very much