【发布时间】:2016-06-20 01:14:04
【问题描述】:
让我们考虑一下函数: 导入数据.Char
convertStringToInt :: String -> Int
convertStringToInt s = convertStringToInt' s 1 0
where
convertStringToInt' [] _ res = res
convertStringToInt' (h:t) m res = convertStringToInt' t (m*10) (res + (((ord h) - 48)*m))
f :: String -> String
f s = (show . convertStringToInt)s
main = interact f
当我输入“1212”时,什么都不会发生。只是提示仍在等待。 为什么?
【问题讨论】:
标签: haskell