Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. -- linked binary tree with characters in the nodes
  2. data Tree = Empty | Node Char Tree Tree
  3. deriving (Show, Eq)
  4.  
  5. -- input as a Tree
  6. input = Node 'a' (Node 'b' (Node 'd' (Node 'g' Empty Empty) (Node 'h' Empty Empty))
  7. (Node 'e' Empty Empty))
  8. (Node 'c' (Node 'f' Empty Empty) Empty)
  9.  
  10. -- solution
  11. pivot Empty = Empty
  12. pivot (Node c l r) = go l (Node c Empty r)
  13. where go Empty rest = rest
  14. go (Node c l r) rest = go l (Node c r rest)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement