[英]haskell list to list pattern matching
這是我的代碼:
newcell :: [Cell] -> [Cell]
newcell [Cell {cellPosition = cp, cellState = cs}]
= [Cell {cellPosition = cp, cellState = (nextCellState cs)}]
nextCellState
只是一個函數,但是它說不能匹配模式。
src/StudentSources/LangtonsAnt.hs:141:1: Warning:
Pattern match(es) are non-exhaustive
In an equation for ‘newcell’:
Patterns not matched:
[]
(Cell _ _) : (_ : _)
您只匹配列表中單個單元格的模式。 再看一下錯誤消息。 它准確地告訴您需要匹配哪些模式。
空列表:
[]
以及列表中多個單元格的模式:
(Cell _ _) : (_ : _)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.