Copyright | Copyright (C) 2021 Yoo Chung |
---|---|
License | GPL-3.0-or-later |
Maintainer | dev@chungyc.org |
Safe Haskell | Safe-Inferred |
Language | GHC2021 |
Part of Ninety-Nine Haskell Problems. Some solutions are in Solutions.P67.
Synopsis
- treeToString :: Tree Char -> String
- stringToTree :: String -> Maybe (Tree Char)
Documentation
treeToString :: Tree Char -> String Source #
Somebody represents binary trees as strings of the following form:
a(b(d,e),c(,f(g,)))
Write a function to generate this string representation from a binary tree.
Examples
>>>
treeToString $ Branch 'x' (Branch 'y' Empty Empty) (Branch 'a' Empty (Branch 'b' Empty Empty))
"x(y,a(,b))"