Created
February 12, 2021 14:07
-
-
Save slice/18d53639dfbd85c42bef53dd4282fe64 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
module Main where | |
import Data.Char (isUpper, toLower) | |
isVowel :: Char -> Bool | |
isVowel = flip elem "aeiou" | |
wuhify :: Char -> Char | |
wuhify c | |
| c == 'r' = 'w' | |
| c == 'R' = 'W' | |
| otherwise = c | |
nyaify :: String -> String | |
nyaify (n:vowel:xs) = | |
if nyaable | |
then nya ++ ns | |
else [n, vowel] ++ ns | |
where | |
nyaable = toLower n == 'n' && (isVowel . toLower) vowel | |
y = | |
if isUpper vowel | |
then "Y" | |
else "y" | |
nya = n : y ++ [vowel] | |
ns = nyaify xs | |
nyaify s = s | |
uvify :: String -> String | |
uvify ('o':'v':'e':xs) = 'u' : 'v' : uvify xs | |
uvify (x:xs) = x : uvify xs | |
uvify "" = "" | |
main :: IO () | |
main = getContents >>= putStr . uvify . nyaify . fmap wuhify |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment