Good day Mr/Mrs :
My name is Patrick , I am a student of the University of Melbourne .
Recently , I have been working on some haskell programms , I have got
a very strange problem .
In my programms , I need to define binary tree , I have got a programm
with which I intended to build a balanced binary tree . The code is listed
below :
data Btree a = Null |
Node a (Btree a ) (Btree a )
deriving ( Eq , Show )
bstBuild :: [a] -> Btree a
bstBuild [] = Null
bstBuild xs = Node midval (bstBuild left ) (bstBuild right)
where
mid = (length xs ) `div` 2
midval = xs !!mid
left = take mid xs
right = dropo (n+1) xs
This program is supposed to output " Null " when an empty list is given .
However , it is not the outcome the computers gives me . Here is the
computer's outcome :
Main> bstBuild []
ERROR: Unresolved overloading
*** type : Eq a => BTree [a]
*** expression : bstBuild []
So , could you tell me where I went wrong , and if it is a bug , how to
correct it ?
All the best .
Sincerely
Patrick
08/06/1999
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com