Skip to content

Instantly share code, notes, and snippets.

@slice
Created February 12, 2021 14:07
Show Gist options
  • Save slice/18d53639dfbd85c42bef53dd4282fe64 to your computer and use it in GitHub Desktop.
Save slice/18d53639dfbd85c42bef53dd4282fe64 to your computer and use it in GitHub Desktop.
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