From e0fff7c4014512bf88b23136dbbb426d9d9b7511 Mon Sep 17 00:00:00 2001 From: Determinant Date: Tue, 30 May 2017 21:57:26 -0400 Subject: finish vol 7 --- 61-69/69.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 61-69/69.hs (limited to '61-69/69.hs') 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 -- cgit v1.2.3