Monday, 6 June 2016

Haskell: Convert list of words to a sentence in upper case


Prelude> import Data.Char
Prelude Data.Char> let wordsToSentence list = [toUpper c | word <- list, c <- ' ' : word]
Prelude Data.Char> 
Prelude Data.Char> wordsToSentence ["Hello", "PTR", "How", "are", "you"]
" HELLO PTR HOW ARE YOU"

Previous                                                 Next                                                 Home

No comments:

Post a Comment