Monday 6 June 2016

Haskell: Convert every character in string to uppercase and remove any digits in it

Following statemet remove digits from a string and convert all lower case characters to uppercase.


getUpper list = [toUpper x | x <- list, not (isDigit x) ]
Prelude> import Data.Char
Prelude Data.Char> 
Prelude Data.Char> let getUpper list = [toUpper x | x <- list, not (isDigit x) ]
Prelude Data.Char> 
Prelude Data.Char> getUpper "Hello ptr123, How are you123"
"HELLO PTR, HOW ARE YOU"
Prelude Data.Char> 


Previous                                                 Next                                                 Home

No comments:

Post a Comment