I hope that this is not a _really_ stupid question, but I have run
into what appears to be a problem using rewrite rules to un-nest
a structure.
The crux of the problem (I have tried to make it as simple as possible
without losing the essence of my difficulty) has to do with duplicating
the structure surrounding the terms that I wish to rewrite.
Any nested list is intended to represent a choice point and my rewrite
rules are aimed at enumerating all of the possible sequences of choices.
An example:
Input:
A[B, C, D[ {F, G}, {H, J}]]
should become
A[B, C, D[F, H]],
A[B, C, D[F, J]],
A[B, C, D[G, J]],
A[B, C, D[G, J]]
Obviously, the order isn't important, but the nesting isn't restricted
to level 2 nor am I guaranteed that all heads or elements are unique.
I realize that I may have to simply write the code that iterates through
the different Depth[]s, but this seems like it might have a very clean
answer that simply hasn't occurred to me.
Thanks,
John A. Gunnels
gunnels at cs.utexas.edu