2016-04-07 20 views
0

İşte benim kod:haskell liste

newcell :: [Cell] -> [Cell] 
newcell [Cell {cellPosition = cp, cellState = cs}] 
= [Cell {cellPosition = cp, cellState = (nextCellState cs)}] 

nextCellState sadece bir fonksiyondur, ancak modelle eşleşen bulamadığını söylüyor.

src/StudentSources/LangtonsAnt.hs:141:1: Warning: 
Pattern match(es) are non-exhaustive 
In an equation for ‘newcell’: 
    Patterns not matched: 
     [] 
     (Cell _ _) : (_ : _) 

cevap

5

Sadece tek bir Hücrenin modelini bir listede eşleştiriyorsunuz. Hata mesajına bir bakın. Tam olarak hangi kalıpları eşleştirmeniz gerektiğini söyler.

boş listesi:

[] 

Ve listede birden fazla Cell modeli:

(Cell _ _) : (_ : _)