diff options
Diffstat (limited to '61-69/69.hs')
-rw-r--r-- | 61-69/69.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/61-69/69.hs b/61-69/69.hs new file mode 100644 index 0000000..63c75b0 --- /dev/null +++ b/61-69/69.hs @@ -0,0 +1,14 @@ +data Tree a = Empty | Branch a (Tree a) (Tree a) deriving (Show, Eq) + +ds2tree :: [Char] -> Tree Char + +ds2tree l = fst $ build l + where build ('.':xs) = (Empty, xs) + build (x:xs) = (Branch x lt rt, xs'') + where (lt, xs') = build xs + (rt, xs'') = build xs' + +tree2ds :: Tree Char -> [Char] + +tree2ds Empty = "." +tree2ds (Branch x l r) = x:tree2ds l ++ tree2ds r |