Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data Tree a = Empty | Node a (Tree a) (Tree a) deriving (Show, Eq)
- showTree :: (Eq a, Show a) => Tree a -> [Tree a] -> Int -> Int -> IO()
- showTree (Node v Empty Empty) list target c = printProcess (Node v Empty Empty) (list ++ [Empty] ++ [Empty]) target c
- showTree (Node v Empty r) list target c = printProcess (Node v Empty r) (list ++ [Empty] ++ [r]) target c
- showTree (Node v l Empty) list target c = printProcess (Node v l Empty) (list ++ [l] ++ [Empty]) target c
- showTree (Node v l r) list target c
- | l == r && l `notElem` list = showTree (Node v l r) (list ++ [l] ++[r]) target c
- | ( l `notElem` list ) = showTree (Node v l r) (list ++ [l]) target c
- | ( r `notElem` list ) = showTree (Node v l r) (list ++ [r]) target c
- | length(list) < 1 = putStr(show v)
- | otherwise = printProcess (Node v l r) list target c
- showTree Empty l t c
- | all (== Empty) l = putStrLn(" Empty ")
- | otherwise = printProcess Empty (l ++ [Empty] ++ [Empty]) t c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement