这是我的代码:
newcell :: [Cell] -> [Cell]
newcell [Cell {cellPosition = cp, cellState = cs}]
= [Cell {cellPosition = cp, cellState = (nextCellState cs)}]
Run Code Online (Sandbox Code Playgroud)
nextCellState 只是一个功能,但它说不能匹配模式.
src/StudentSources/LangtonsAnt.hs:141:1: Warning:
Pattern match(es) are non-exhaustive
In an equation for ‘newcell’:
Patterns not matched:
[]
(Cell _ _) : (_ : _)
Run Code Online (Sandbox Code Playgroud)
您只匹配列表中单个单元格的模式.再看一下错误消息.它会准确地告诉您需要匹配的模式.
空列表:
[]
Run Code Online (Sandbox Code Playgroud)
以及列表中多个Cell的模式:
(Cell _ _) : (_ : _)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
58 次 |
| 最近记录: |