如果不是,我想制作字符串的第一个字符。这就是我正在做的事情:
import Data.Char
onlyCapitals :: [String] -> [String]
onlyCapitals [] = []
onlyCapitals (x:xs) = if isUpper $ head x
then x ++ onlyCapitals xs -- 1
else toUpper (head x) : tail x ++ onlyCapitals xs -- 2 and 3
main = print $ onlyCapitals ["Aaaa", "bbb", "ffff"]
我得到了3个错误:
Couldn't match type `Char' with `[Char]'
Expected type: [String]
Actual type: String
Couldn't match type `Char' with `[Char]'
Expected type: String
Actual type: Char
Couldn't match type `Char' with `[Char]'
Expected type: [String]
Actual type: String