Skip to content

Instantly share code, notes, and snippets.

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