Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我试图实现一个最大函数,但由于某种原因,我在最后一行 "mymax x:y:ys = ....." 上遇到了一个解析错误。该错误的原因是什么?谢谢!
mymax :: Ord a=>[a]->Maybe a mymax [] = Nothing mymax [x] = Just x mymax x:y:xs = if (x < y) then mymax(y:xs) else mymax(x:xs)
您缺少括号:
mymax (x:y:xs) = if (x < y) ...
用括号括起来x:y:xs
x:y:xs
mymax (x:y:xs) = ...