Suppose I have a list of the form:
list = {a, b, {c, d}, f, {g, h}}
i.e. an element of the list could be another list. I want to 'thread' each element of the sublist, so for the above result I should obtain 4 lists:
{{a,b,c,f,g},{a,b,d,f,g},{a,b,c,f,h},{a,b,d,f,h}}
The list could have arbitrary size and the sublist are arbitrarily distributed. How can I do it?
NOTE: Originally I am trying to map expressions involving AND and OR into lists of the AND elements, e.g.
a && b && ( c || d ) && f && (g || h)
should be mapped to
{{a,b,c,f,g},{a,b,d,f,g},{a,b,c,f,h},{a,b,d,f,h}}
I concluded that substituting AND and OR by list was a good start, hence the above statement of the problem.