Skip to content

Instantly share code, notes, and snippets.

@lattejed
Created June 1, 2013 17:43
Show Gist options
  • Save lattejed/5691139 to your computer and use it in GitHub Desktop.
Save lattejed/5691139 to your computer and use it in GitHub Desktop.
-- Make a pattern to match the consonants and vowels in a word where a cons is
-- not "aeiou" or y preceded by a cons e.g., "happy" -> ("happy", "cvccv")
wordDesc :: String -> (String, String)
wordDesc str =
(str, [corv (a,b,i) | (a,b,i) <- zip3 str (rotateR str) [0..len]])
where len = length str - 1
corv (a,b,i)
| a == 'y' && i /= 0 && b `notElem` vs = 'v'
| a `elem` vs = 'v'
| otherwise = 'c'
where vs = "aeiou"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment