[Haskell-cafe] Extracting all pruned sub trees

Tom Hawkins tomahawkins at gmail.com
Wed Jan 20 13:09:12 EST 2010


I'm looking for an elegant way to generate a list of all pruned trees
where each pruned tree has one of its leaves removed.  Something like
this:

data Leaf = ...

data Tree = Leaf Leaf | Branch [Tree]

prunedSubTrees :: Tree -> [(Leaf, Tree)]    -- [(the leaf removed, the
pruned tree)]

Any suggestions?


More information about the Haskell-Cafe mailing list