
Draw the trees, and then try to partition every node into (left, element,
right).
For example, in your first example (Node leaf "msg 1" leaf), we get
Node "msg 1"
├── leaf
└── leaf
In the second example,
Node "msg 1"
├── leaf
└── Node "msg 2" -- A sub-tree
├── leaf
└── leaf
Now, substituting a leaf with a Node in the above tree will lead to larger
trees.
For another example, look here:
http://en.wikipedia.org/wiki/Tagged_union#Examples
On 28 February 2015 at 14:10, Roelof Wobben
Hello,
I found out that for 1 item I can do this : node = Node leaf "msg 1" leaf And for 2 items I can do this : node = Node leaf "msg1" (Node leaf "msg2" leaf)
But now I wonder how I can make this work with recursion. It seems that I keep the first 2 items and change the 3th one from leaf to another node
Roelof
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-- Regards Sumit Sahrawat