Tree handling
Martin Gustafsson
martin-g@home.se
Mon, 26 Feb 2001 15:05:50 +0100
This is a multi-part message in MIME format.
------=_NextPart_000_0006_01C0A005.9B381B40
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hello=20
I'm a haskell newbie that tries to create a tree with arbitary numbers =
of childs.=20
I create the data structure but i can't do anything on it can someone =
please help
me with a small function that sums the values of the leafs, so i don=B4t =
loose my hair
so fast.
The datastructure looks like this and a binary tree built with it would =
look like this:
data GeneralTree =3D Nil | Node (Integer,[GeneralTree])
tree =3D=20
(20,
[
(-20,[(30,[Nil]),(20,[Nil])]),
(40,[(65,[Nil]),(-40,[Nil])])
]
)
=20
Best regards
Martin Gutsfsson
------=_NextPart_000_0006_01C0A005.9B381B40
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>I'm a haskell newbie that tries to =
create a tree=20
with arbitary numbers of childs. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I create the data structure but i can't =
do anything=20
on it can someone please help</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>me with a small function that sums the =
values of=20
the leafs, so i don=B4t loose my hair</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>so fast.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>The datastructure looks like this and a =
binary tree=20
built with it would look like this:</FONT></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>data GeneralTree =3D Nil | Node=20
(Integer,[GeneralTree])</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2><BR>tree =3D=20
<BR> (20,<BR> [<BR> (-=
20,[(30,[Nil]),(20,[Nil])]),<BR> (40,[(65,[Nil]),(=
-40,[Nil])])<BR> ]<BR> )<BR> <BR></FONT>=
</DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Best regards</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>Martin =
Gutsfsson</FONT></DIV></BODY></HTML>
------=_NextPart_000_0006_01C0A005.9B381B40--