ninetynine-1.3.0: Ninety-Nine Haskell Problems
CopyrightCopyright (C) 2023 Yoo Chung
LicenseGPL-3.0-or-later
Maintainerdev@chungyc.org
Safe HaskellSafe-Inferred
LanguageGHC2021

Solutions.P70

Description

Some solutions to Problems.P70 of Ninety-Nine Haskell Problems.

Synopsis

Documentation

stringToMultitree :: String -> Maybe (MultiwayTree Char) Source #

We suppose that the nodes of a multiway tree contain single characters. The characters in the node string are in depth-first order of the tree. The special character ^ is inserted whenever the move is a backtrack to the previous level during tree traversal. Note that the tree traversal will also backtrack from the root node of the tree.

Write a function to construct the MultiwayTree when the string is given.

multitreeToString :: MultiwayTree Char -> String Source #

Construct the node string from a MultiwayTree.