[Haskell-cafe] Construct all possible trees
lemming at henning-thielemann.de
Wed Jun 13 08:17:56 EDT 2007
On Thu, 14 Jun 2007, Tom Pledger wrote:
> *Andrew Coppin wrote:
> | I'm trying to construct a function
> | all_trees :: [Int] -> [Tree]
> | such that all_trees [1,2,3] will yield
> If you write a helper function that takes an N element list, and returns
> all 2^N ways of dividing those elements into 2 lists, e.g.
> splits "ab" --> [("ab",""),("b","a"),("a","b"),("","ab")]
> then you can use it both for dividing the initial list into kept and
> discarded elements, and for dividing a list between a left subtree and a
> right subtree.
This one was discussed recently:
More information about the Haskell-Cafe