Phi*_*hil 12

Hoogle是你的朋友:

http://haskell.org/hoogle/?hoogle=Char+-%3E+Int

import Data.Char   
ord 'a'
chr 98
Run Code Online (Sandbox Code Playgroud)

  • 还有`fromEnum` /`toEnum`:`fromEnum'a'== 97`,`(toEnum 97 :: Char)=='a'`. (4认同)
  • @devoured elysium - 你可能会考虑接受你新朋友的回答.:-) (2认同)
  • 我更喜欢使用`fromEnum` /`toEnum`.不记得了,因为它们适用于更多类型:) (2认同)