Advertisement
Guest User

Untitled

a guest
May 26th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. showTree :: Show a => AVLTree a -> String -> String
  2. showTree Leaf h = "-Leaf"
  3. showTree (Node val h Leaf Leaf) intro = "-" ++ show val
  4. showTree (Node val h l Leaf) intro =
  5. "-" ++ show val ++ "\n" ++
  6. intro ++ " |\n" ++
  7. intro ++ " `" ++ showTree l (intro ++ " ")
  8. showTree (Node val h Leaf r) intro =
  9. "-" ++ show val ++ "\n" ++
  10. intro ++ " |\n" ++
  11. intro ++ " `" ++ showTree r (intro ++ " ")
  12. showTree (Node val h l r) intro =
  13. "-" ++ show val ++ "\n" ++
  14. intro ++ " |\n" ++
  15. intro ++ " +" ++ showTree l (intro ++ " |") ++ "\n" ++
  16. intro ++ " |\n" ++
  17. intro ++ " `" ++ showTree r (intro ++ " ")
  18.  
  19.  
  20. instance Show a => Show (AVLTree a) where
  21. show tree = showTree tree ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement