Expanding a nested structure (pattern matching?)

*To*: mathgroup at smc.vnet.net*Subject*: [mg24835] Expanding a nested structure (pattern matching?)*From*: "John A. Gunnels" <gunnels at cs.utexas.edu>*Date*: Tue, 15 Aug 2000 03:04:06 -0400 (EDT)*Organization*: University of Texas at Austin*Sender*: owner-wri-mathgroup at wolfram.com

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