Created
July 21, 2021 06:32
-
-
Save jessecogollo/244a9bdb94b99d05e49fa16303cc9ad8 to your computer and use it in GitHub Desktop.
Ejercicio deletreador en Haskell
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 ++ ", " | |
deletreador :: [[Char]] -> [Char] | |
deletreador words | |
| words == [] = "" | |
| length words == 1 = createSinglePhrase (head words) | |
| otherwise = let x:xs = words in createPhrase x xs ++ deletreador xs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment