所以我必须创建一个函数来找到一对第一个字母并返回第二个字母。
我实际上找到了一个答案,但使用地图功能却无法得到它。
lookUp :: Char -> [(Char, Char)] -> Char
lookUp x [] = x
lookUp x ( ( st,nd ): rst) | st == x = nd
| otherwise = lookUp x rst
我收到这条消息:
No instance for (Show ([(Char, Char)] -> Char))
arising from a use of `print'
Possible fix:
add an instance declaration for (Show ([(Char, Char
In a stmt of an interactive GHCi command: print it