Created
June 28, 2021 04:59
-
-
Save jessecogollo/4cd5f6b2e8364bdaf67e38c462e4557e to your computer and use it in GitHub Desktop.
speller exersise
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
getLetter :: [Char] -> [Char] | |
getLetter word = | |
take 1 word | |
createSinglePhrase :: [Char] -> [Char] | |
createSinglePhrase word = | |
getLetter word ++ " is for " ++ word | |
createPhrase :: [Char] -> [[Char]] -> [Char] | |
createPhrase word lst = | |
if ( length lst == 1 ) | |
then createSinglePhrase word ++ ", and " | |
else createSinglePhrase word ++ ", " | |
speller :: [[Char]] -> [Char] | |
speller words | |
| words == [] = "" | |
| length words == 1 = createSinglePhrase (head words) | |
| otherwise = let x:xs = words in createPhrase x xs ++ speller xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment