1

これを呼んでいると、ケース定義が欠落しています

check c (n:nx) state (l:ls,r:rs)
=true,if((isprefix state c)&(r=n))
=false, otherwise

私はこれをチェックしました、そしてそれは私がそれを何を送ってもそれ自身で働きます。

これは私がそれを呼んでいるところです(警告:それは今のところ少しひどく書かれています):

readword input state tape
=output tape, if (((haltcheck sWord sNum state tape)=true)&(isprefix " halt" rline))
=doinst rline state tape , if ((check sWord sNum state tape)=true)
=readword tail state tape, otherwise
  where
  theline = dropwhile notit input
  start = dropwhile  isspace theline
  sWord = takewhile letter start
  ends = dropwhile notspace start 
  distart = dropwhile isspace ends
  sNum = takewhile notspace distart
  tail = dropwhile notspace distart
  rline = takewhile notit tail
4

1 に答える 1

1

ケース定義がないということは、パターンマッチングを行っており、すべてのケースを網羅しているわけではないことを意味します。これは、関数の定義で2回発生しますcheck。2番目のパラメーターをパターンと一致させますが、パターンとは一致させn:nxません[](したがって、2番目の引数が空のリストである可能性がある場合については説明しません)。(l:ls, r:rs)同様に、ペアの要素のいずれかが空のリストである可能性を考慮せずに、4番目の引数をと照合しています。

したがって、エラーの原因は、呼び出し元checkが空であるreadwordsNum、のリストの1つが空であるということですtape

于 2011-11-06T21:31:00.730 に答える