【发布时间】:2023-03-22 18:32:01
【问题描述】:
如何在 Haskell 中获取字符的 ASCII 值?我尝试在 GHCi 中使用 ord 函数,根据我阅读的 here 错误消息:
不在范围内:`ord'
例如:
GHCi, version 6.12.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> ord 'a'
<interactive>:1:0: Not in scope: `ord'
Prelude>
我做错了什么?
【问题讨论】:
-
:module +Data.Char(在 GHCi 中)或import Data.Char(在您的源文件中)。 -
@Travis Brown:你也可以在 ghci 中做
import Data.Char -
@newacct:酷——我不知道。
qualified&c。但是,显然不起作用。 -
@TravisBrown
qualified工作!