[Haskell-cafe] Construct all possible trees

Colin DeVilbiss cdevilbiss at gmail.com
Tue Jun 12 16:20:31 EDT 2007


On 6/12/07, Andrew Coppin <andrewcoppin at btinternet.com> wrote:

Based on the sample output, I'm guessing that the desired output is
"every tree which, when flattened, gives a permutation of a non-empty
subset of the supplied list".  This limits the output to trees with up
to "n" leaves.

> Branch (Branch (Leaf 1) (Leaf 3)) (Leaf 1),

If I'm guessing the desired output correctly, this must be a typo?

I'd be tempted to solve the "list-only" problem first (generate all
"sub-permutations" of a list), then solve the tree problem (generate
all "un-flattenings" of a list).

Colin DeVilbiss


More information about the Haskell-Cafe mailing list