On 12/2/07, Don Stewart <[EMAIL PROTECTED]> wrote: > prstanley: > > 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. > > You could probably get away with: > > data Tree = Leaf !Int | Node Tree !Int Tree > > but that's a minor issue. >
IMO, there's no reason to even think about putting in the strictness annotations unless you've identified this datatype as part of a performance bottleneck in production code. Otherwise, there's no need to clutter your code and your mind with them :-) Cheers, Tim -- Tim Chevalier * catamorphism.org * Often in error, never in doubt "Base eight is just like base ten, really... if you're missing two fingers." -- Tom Lehrer _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe