-
-
Save chowells79/8208a95fcabc2ac73d1283cdf422fc27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Ptree a = Pnode a [Ptree a] deriving (Eq, Show) | |
ptLeaf :: Char -> Ptree Char | |
ptLeaf c = Pnode c [] | |
ptInsert :: String -> Ptree Char -> Ptree Char | |
pInsert [] tree = tree | |
ptInsert (c:cs) (Pnode v children) = case children of | |
[] -> undefined -- the node has no children | |
(current:rest) | v == c -> undefined -- the node has children, and the first one is what we're looking for | |
| otherwise -> undefined -- the node has children, but the first one is not what we're looking for |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment