[Begginer] Some bintree problems

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[Begginer] Some bintree problems

This post has NOT been accepted by the mailing list yet.
Hi, I would like to ask you if you can help me with this problem...
So i would like to take numbers from my bintree and count them together my code looks like this

data BinTree a = Empty | Node a (BinTree a) (BinTree a) deriving (Eq,Show)
sumtree (Node Empty _ _) = 0
sumtree (Node v l r) = v + (sumtree l) + (sumtree r)

tn = Node 4 (Node 3 Empty Empty) (Node 4 Empty Empty)

If someone can explain me where i do mistakes, thanks for your time...