Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
IvoTod committed Nov 1, 2016
1 parent 9bf71c4 commit 0c29599
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions exercises/secret-lang/Secret-lang.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,27 @@ isInString char (first:rest)


isVowel :: Char -> Bool
isVowel char
| isInString (toLower char) vowels == True = True
isVowel _ = False
isVowel char = isInString (toLower char) vowels


isConsonant :: Char -> Bool
isConsonant char
| isVowel char == False && isChar char == True = True
| not (isVowel char) && isChar char = True
| otherwise = False


encode :: String -> String
encode [] = []
encode (first:rest)
| isConsonant first == True = first : 'o' : first : (encode rest)
| isConsonant first = first : 'o' : first : (encode rest)
| otherwise = first:(encode rest)


-- Bonus #1
encode' :: String -> String
encode' [] = []
encode' (first:rest)
| isConsonant first == True = first : 'o' : toLower first : (encode' rest)
| isConsonant first = first : 'o' : toLower first : (encode' rest)
| otherwise = first:(encode' rest)


Expand Down

0 comments on commit 0c29599

Please sign in to comment.