<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix"><br>
That part I understand .<br>
<br>
it's more how I do it here :<br>
<br>
Lets say I have this : <br>
<br>
data MessageType = Info<br>
| Warning<br>
| Error Int<br>
deriving (Show, Eq)<br>
<br>
type TimeStamp = Int<br>
<br>
data LogMessage = LogMessage MessageType TimeStamp String<br>
| Unknown String<br>
deriving (Show, Eq)<br>
<br>
data MessageTree = Leaf<br>
| Node MessageTree LogMessage MessageTree<br>
deriving (Show, Eq)<br>
<br>
Now I have to put all the LogMessages in a binary tree.<br>
with this signature : insert :: LogMessage -> MessageTree ->
MessageTree<br>
<br>
I think I need recursion here but I still not see how I can make
the clauses. <br>
Normally you can say somethig like this [] -> 0 or 1 ->
but here it seems to be all seperate logMessages <br>
<br>
Roelof<br>
<br>
<br>
<br>
<br>
<br>
Sumit Sahrawat, Maths & Computing, IIT (BHU) schreef op
28-2-2015 om 11:53:<br>
</div>
<blockquote
cite="mid:CAJbEW8M64z7V1WESUOYtG59gDM9xX-z28TpYC+P_hpegioJW5Q@mail.gmail.com"
type="cite">
<div dir="ltr">Draw the trees, and then try to partition every
node into (left, element, right).
<div><br>
</div>
<div>For example, in your first example (Node leaf "msg 1"
leaf), we get</div>
<div><br>
</div>
<div><font face="monospace, monospace">
<div>Node "msg 1"</div>
<div>├── leaf</div>
</font>
<div style="font-family:monospace,monospace">└── leaf</div>
<div style="font-family:monospace,monospace"><br>
</div>
In the second example,</div>
<div><br>
<font face="monospace, monospace">
<div>Node "msg 1"</div>
<div>├── leaf</div>
</font><font face="monospace, monospace">
<div>└── Node "msg 2" -- A sub-tree</div>
</font><font face="monospace, monospace">
<div> ├── leaf</div>
<div> └── leaf</div>
<div><br>
</div>
</font>Now, substituting a <font face="monospace, monospace">leaf</font> with
a <font face="monospace, monospace">Node</font> in the above
tree will lead to larger trees.</div>
<div>For another example, look here: <a moz-do-not-send="true"
href="http://en.wikipedia.org/wiki/Tagged_union#Examples">http://en.wikipedia.org/wiki/Tagged_union#Examples</a></div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 28 February 2015 at 14:10, Roelof
Wobben <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:r.wobben@home.nl" target="_blank">r.wobben@home.nl</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I found out that for 1 item I can do this : node = Node leaf
"msg 1" leaf<br>
And for 2 items I can do this : node = Node leaf "msg1"
(Node leaf "msg2" leaf)<br>
<br>
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<br>
<br>
Roelof<br>
<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a moz-do-not-send="true"
href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a moz-do-not-send="true"
href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe"
target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div dir="ltr">
<div>Regards</div>
<div dir="ltr">
<div><br>
</div>
<div>Sumit Sahrawat</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
</body>
</html>