我试图在Haskell中实现一个凯撒密码。当我运行此代码时,我得到一个"解析输入' =' &#34 ;.应该改变什么?我将其从源文件(Sublime)加载到ghci。
import Data.Char
let2int :: Char -> Int
let2int c = ord c - ord 'a'
int2let :: Int -> Char
int2let n = chr (ord 'a' + n)
shift :: Int -> Char -> Char
shift n c
| isLower c = int2let ((let2int c + n) `mod` 26)
| otherwise = c
encode :: Int -> String -> String
encode n xs = [shift n x | x <- xs]
答案 0 :(得分:3)
encode
与其他顶级定义的起始位置不同。删除多余的空间。