Monday, 6 June 2016

Haskell: Convert character to string


StringUtil.hs
charToString :: Char -> String
charToString c = [c]

Prelude> :load StringUtil.hs
[1 of 1] Compiling Main             ( StringUtil.hs, interpreted )
Ok, modules loaded: Main.
*Main> 
*Main> charToString 'a'
"a"
*Main> 
*Main> charToString '1'
"1"
*Main>


Previous                                                 Next                                                 Home

No comments:

Post a Comment