On Mon, Dec 03, 2007 at 05:20:35AM +0000, PR Stanley wrote: > Hi > data Tree = Leaf Int | Node Tree Int Tree > > occurs :: Int -> Tree -> Bool > occurs m (Leaf n) = m == n > occurs m (Node l n r) = m == n || occurs m l || occurs m r > > It works but I'd like to know if it can be improved in any way. > Thanks, Paul
I'm not sure this will count as improvement, but you can build the same kinds of trees with a simpler datatype: data Tree = Empty | Node Tree Int Tree This way there is only one constructor with the Int value, which can simplify other code a bit. Best regards Tomasz _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
