Sunday 5 June 2016

Haskell: get ASCII value of a character


Data.Char module provides ord function, which takes a character and return ASCII value of it.
Prelude> :m Data.Char
Prelude Data.Char> 
Prelude Data.Char> ord 'a'
97
Prelude Data.Char> ord 'b'
98
Prelude Data.Char> ord '@'
64
Prelude Data.Char> ord '`'
96
Prelude Data.Char> :t ord
ord :: Char -> Int
Prelude Data.Char> 


Previous                                                 Next                                                 Home

No comments:

Post a Comment