Say I have some list of lists [[a, b], [c], [d, e, f], ...]
where the lists in the list can be any length. I've sorted the list such that the shortest lists come first, and I want to generate a list of all combinations of elements in the lists such that I get a list [[a, c, d, ...], [a, c, e, ...], [a, c, f, ...], [b, c, d, ...], ...]
, i.e. the combinations are generated by changing the element picked from the last lists first, moving up lists to change elements similar to counting.
Using this list, I'll take the head of the list to use lazy evaluation as I only need 1 list that satisfies the predicate. How do I generate the list?