3
的 “图案解析错误” 这是我的代码:哈斯克尔:哪里是
connected :: [(Integer,Integer)] -> Bool
connected [] = True
connected [(_,_)] = True
connected (a,b):(c,d):xs
| a > c = False
|otherwise = connected (c,d):xs
当我加载它GHCI它显示
error: parse error in pattern: connected
哪儿了我犯了一个错误?
小调注意:'foo | x = False |否则= something'是(IMO)更常被写为'foo = not x && something'。在你的情况下,你可以使用'connected(...)= a <= c && connected(...)'。 – chi