Last active
May 7, 2018 13:22
-
-
Save ironhouzi/2392e1aabf164a4937659017870762ef 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
alpha = ["K", "Kh", "G", "Ng", "C", "Ch", "J", "Ny", "T", "Th", "D", "N", "P", "Ph", "B", "M", "Ts", "Tsh", "Dz", "W", "Zh", "Z", "'", "Y", "R", "L", "Sh", "S", "H", "A", "I", "U", "E", "O"] | |
data Ptree a = Pnode a [Ptree a] deriving (Eq, Show) | |
ptAdd :: String -> Ptree Char | |
ptAdd (c:cs) | |
| cs == [] = Pnode c [] | |
| otherwise = Pnode c [ptAdd cs] | |
ptInsert :: String -> [Ptree Char] -> [Ptree Char] | |
ptInsert [] t = t | |
ptInsert s [] = [ptAdd s] | |
ptInsert (c:cs) ((Pnode v ch) : xs) | |
| c == v = (Pnode v (ptInsert cs ch)) : xs | |
| otherwise = [(Pnode v ch)] ++ (ptInsert (c:cs) xs) |
Author
ironhouzi
commented
May 7, 2018
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment