【发布时间】:2018-06-02 13:53:17
【问题描述】:
我有这个代码:
censName :: String -> String
censName [] = []
censName xs = unwords(censWords(words xs))
censWords :: [String] -> [String]
censWords [] = []
censWords (x:xs) = if isUpper(head x) then replace(tail x) else censWords xs
replace :: String -> String
replace [] = []
replace (x:xs) = '*':replace xs
错误提示:
Couldn't match type ‘Char’ with ‘[Char]’
Expected type: [String]
Actual type: String
我的问题是:为什么!?我的意思是,在 replace(tail x) x 中,x 是一个字符串,那么为什么它需要 [String]?
在此处发布的类似问题上,我找不到适合我的问题的任何内容。
【问题讨论】:
标签: haskell