这是我尝试使用的
validDate :: Int -> Int -> Bool
validDate d m
| d <= 31 && m elem highMonths = True
| d <= 30 && m elem lowMonths = True
| d <= 28 && m == 2 = True
| otherwise = False
where
highMonths = [1, 3, 5 , 7, 8, 10, 12]
lowMonths = [4, 6, 9, 11]
但是它给我扔了一个我不太明白的错误。
WS1.hs:73:22:
Couldn't match expected type ‘(a0 -> [a0] -> Bool) -> [t1] -> Bool’
with actual type ‘Int’
Relevant bindings include highMonths :: [t1] (bound at WS1.hs:78:9)
The function ‘m’ is applied to two arguments,
but its type ‘Int’ has none
In the second argument of ‘(&&)’, namely ‘m elem highMonths’
In the expression: d <= 31 && m elem highMonths
我不知道我哪里出了错,任何帮助表示赞赏。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句