summaryrefslogtreecommitdiff
path: root/70b-73/70.hs
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2017-05-31 00:32:37 -0400
committerDeterminant <ted.sybil@gmail.com>2017-05-31 00:32:37 -0400
commit34d130005be780756b9c6915a7c188a756e03882 (patch)
tree4a5b1ca11e87086adc081e428561b3230abb38cb /70b-73/70.hs
parente0fff7c4014512bf88b23136dbbb426d9d9b7511 (diff)
finish vol 8
Diffstat (limited to '70b-73/70.hs')
-rw-r--r--70b-73/70.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/70b-73/70.hs b/70b-73/70.hs
new file mode 100644
index 0000000..69f42f5
--- /dev/null
+++ b/70b-73/70.hs
@@ -0,0 +1,16 @@
+data Tree a = Node a [Tree a] deriving (Eq, Show)
+
+stringToTree :: [Char] -> Tree Char
+
+stringToTree l = fst $ build l
+ where build (x:xs) = (Node x chd'', xs'')
+ where loop ('^':xs) = ([], xs)
+ loop xs = (chd':c, x)
+ where (chd', xs') = build xs
+ (c, x) = loop xs'
+ (chd'', xs'') = loop xs
+
+
+treeToString :: Tree Char -> [Char]
+
+treeToString (Node v xs) = v:(concat $ map treeToString xs) ++ "^"