[Haskell-cafe] how to make this work recursive ?

Sumit Sahrawat, Maths & Computing, IIT (BHU) sumit.sahrawat.apm13 at iitbhu.ac.in
Sat Feb 28 10:53:06 UTC 2015


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 <r.wobben at home.nl> wrote:

> 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 at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>



-- 
Regards

Sumit Sahrawat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150228/0edbec0b/attachment.html>


More information about the Haskell-Cafe mailing list