Bohtvaroh

Blogger - Folding tree - 1 (Haskell)

Jun 5th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module TreeToList (Tree (Empty, Node), toList) where
  2.  
  3. data Tree a = Empty | Node a (Tree a) (Tree a) deriving (Show)
  4.  
  5. toList :: Tree a -> [a]
  6. toList Empty               = []
  7. toList (Node a left right) = (toList left) ++ a : toList right
Advertisement
Add Comment
Please, Sign In to add comment