[Haskell-beginners] N-ary tree search problems

iæfai iaefai at me.com
Thu Nov 5 22:10:04 EST 2009


Try to make sure things are lined up properly, like the Empty and  
Left, and why are some gtreeMember indented?

On 2009-11-04, at 7:04 AM, Ryan Temple wrote:

> I'm making a general purpose N-ary tree and im coming up with  
> "unexpected
> '=' on line 17" as an error.  I have spent a fair while trying to  
> work out
> why this isn't accepting the case that an Empty gtree returns false  
> for any
> member search.  i realise this is probably a very trivial error but  
> any help
> would be appreciated:
>
> module GTrees where
>
> data Gtree = Empty |
>             Leaf String |
>             Node String [Gtree]
>             deriving (Show)
>
> --Tests if a given string is a member of the tree
>
> gtreeMember :: (Ord a) => a -> Gtree a -> Bool
>  gtreeMember y Empty = False  -- line 17
>  gtreeMember y (Leaf x) = (x==y)
>  gtreeMember y (Node x tree)
>      |x==y = True
>      |otherwise gtreeMember tree
>
> This is the code up to the point of the error with the error line
> highlighted
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners



More information about the Beginners mailing list