Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. data Tree a = Empty | Node a (Tree a) (Tree a) deriving (Show, Eq)
  2.  
  3. showTree :: (Eq a, Show a) => Tree a -> [Tree a] -> Int -> Int -> IO()
  4.  
  5. showTree (Node v Empty Empty) list target c = printProcess (Node v Empty Empty) (list ++ [Empty] ++ [Empty]) target c
  6. showTree (Node v Empty r) list target c = printProcess (Node v Empty r) (list ++ [Empty] ++ [r]) target c
  7. showTree (Node v l Empty) list target c = printProcess (Node v l Empty) (list ++ [l] ++ [Empty]) target c
  8. showTree (Node v l r) list target c
  9. | l == r && l `notElem` list = showTree (Node v l r) (list ++ [l] ++[r]) target c
  10. | ( l `notElem` list ) = showTree (Node v l r) (list ++ [l]) target c
  11. | ( r `notElem` list ) = showTree (Node v l r) (list ++ [r]) target c
  12. | length(list) < 1 = putStr(show v)
  13. | otherwise = printProcess (Node v l r) list target c
  14.  
  15. showTree Empty l t c
  16. | all (== Empty) l = putStrLn(" Empty ")
  17. | otherwise = printProcess Empty (l ++ [Empty] ++ [Empty]) t c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement