Friday 3 June 2016

Haskell: ord: Convert character to integer

Data.Char module provides ord function, which takes a character and return the corresponding unicode value. Following is the signature of ord function.

ord :: Char -> Int

Prelude> :m Data.Char
Prelude Data.Char> :t ord
ord :: Char -> Int
Prelude Data.Char> 
Prelude Data.Char> ord 'a'
97
Prelude Data.Char> ord '@'
64
Prelude Data.Char> ord '='
61


Previous                                                 Next                                                 Home

No comments:

Post a Comment