<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif;font-size:small">Roelof,</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">Perhaps it would help for you to draw diagrams for the cases you're working.</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">If a leaf has nothing below it, and a node always has exactly three things below it (the left child, the message, and the right child),<br></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">what would your picture look like for 1, 2, and 3 nodes?</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">And how would you write out constructor expressions that match those shapes?</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br></div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">Hope that helps,</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small">-jn-</div><div class="gmail_default" style="font-family:georgia,serif;font-size:small"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 26, 2015 at 12:32 PM, Roelof Wobben <span dir="ltr"><<a 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">
<div bgcolor="#FFFFFF" text="#000000">
Oke, <br>
<br>
I send it a second time but now in plain text.<br>
<br>
So for 3 it will be like this : <br>
<br>
Node = Node (Node Leaf "msg1" Leaf) (Node Leaf "msg2") (Node
"msg3" Leaf) ???<div><div class="h5"><br>
<br>
Roelof<br>
<br>
<br>
<br>
<blockquote type="cite">
<div> <br>
<br>
Konstantine Rybnikov schreef op 26-2-2015 om 15:08:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>
<div>In my second example you can see a minimal node with a
message:<br>
<br>
node = Node Leaf "msg" Leaf<br>
<br>
</div>
Instead of either left or right Leaf you can put another
value of type MessageTree, for example:<br>
<br>
</div>
node = Node Leaf "msg1" (Node Leaf "msg2" Leaf)<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Feb 26, 2015 at 4:01 PM,
Roelof Wobben <span dir="ltr"><<a 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">
<div bgcolor="#FFFFFF" text="#000000">
<div>Oke, <br>
<br>
So a leaf is a node which has no "branch"<br>
<br>
I have made a exercise where I have to made the
logMessages. <br>
Now I have to turn them into a tree <br>
<br>
Where does the second entry goes then ?<br>
<br>
Roelof<br>
<br>
<br>
Konstantine Rybnikov schreef op 26-2-2015 om 14:56:<br>
</div>
<div>
<div>
<blockquote type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>
<div>Hi Roelof,<br>
<br>
</div>
I think you misunderstood it.<br>
<br>
</div>
<div>There are two things here: types
and values (value-constructors).
They exist in different world, not
touching each other.<br>
<br>
</div>
<div>In Haskell, you define a type as:<br>
<br>
</div>
<div>data <Type_Name> =
<ValueConstructor_Name>
<Type_Name> <Type_Name>
<Type_Name><br>
<br>
</div>
<div>You can create values as:<br>
<br>
</div>
<div>let varName =
<ValueConstructor_Name>
<Value> <Value>
<Value><br>
<br>
</div>
<div>You need to put <Value> of
some type, not type name itself in
place of those <Value>s.<br>
<br>
</div>
<div>So, with datatype you provided,
you have two data-constructors:<br>
<br>
</div>
<div>Leaf<br>
<br>
</div>
<div>and<br>
<br>
</div>
<div>Node <val> <val>
<val><br>
<br>
</div>
<div>You can create a leaf:<br>
<br>
</div>
<div>let leaf = Leav<br>
<br>
</div>
<div>or a node:<br>
<br>
</div>
<div>let node = Node Leaf "msg" Leaf<br>
<br>
</div>
<div>You can see that Node is a
data-constructor that takes 3
values, not type-names as it's
parameters.<br>
<br>
</div>
<div>Hope this helps.<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Thu, Feb 26, 2015 at
3:21 PM, Roelof Wobben <span dir="ltr"><<a 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>
Suppose we have this definition of a tree :<br>
<br>
data MessageTree = Leaf<br>
| Node MessageTree
LogMessage MessageTree<br>
deriving (Show, Eq)<br>
<br>
let Message = LogMessage "E 1 this is a
test error"<br>
let Message = LogMessage "e 2 this is the
second test error "<br>
<br>
As I understand it right I can make the
first entry like this : first_entry = Node
Messagetree Message Messagetree<br>
<br>
And the second one like this second_entry =
Node Message Messagetree Message2
Messagetree ??<br>
<br>
Roelof<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
Beginners mailing list
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a>
</pre>
</blockquote>
<br>
</div>
</div>
</div>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
Beginners mailing list
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a>
</pre>
</blockquote>
<br>
</blockquote>
<br>
</div></div></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Beauty of style and harmony and grace and good rhythm depend on simplicity. - Plato</div>
</div>