data InternalTree a = ILeaf | IBranch a (InternalTree a) (InternalTree a) deriving Show takeTree :: Int -> InternalTree a -> InternalTree a takeTree 0 t = ILeaf takeTree n ILeaf = ILeaf takeTree n (IBranch a x y) = IBranch a (takeTree (n-1) x) (takeTree (n-1) y) takeTreeWhile :: (a -> Bool) -> InternalTree a -> InternalTree a takeTreeWhile f ILeaf = ILeaf takeTreeWhile f (IBranch a x y) = if (f a) then IBranch a (takeTreeWhile f x) (takeTreeWhile f y) else ILeaf |
(Technical error 13 applies to this exercise.)