diff options
author | Determinant <ted.sybil@gmail.com> | 2017-05-30 21:57:26 -0400 |
---|---|---|
committer | Determinant <ted.sybil@gmail.com> | 2017-05-30 21:57:26 -0400 |
commit | e0fff7c4014512bf88b23136dbbb426d9d9b7511 (patch) | |
tree | 91a824a850b3e5f0d60f1f065e092e4accee9790 /61-69/69.hs | |
parent | 626a548f0ef51b5ee1d3ba049330317f94c89f99 (diff) |
finish vol 7
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 |