2011-11-06 4 views
2

에 나는 누락 된 경우 정의를 얻고있다.누락 된 경우 정의는 미란다

내가에서 호출하고있어 곳입니다 (경고 :이 심하게 지금 작성된 비트의) :

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 

답변

2

경우 정의를 누락하면 패턴 매칭있어 것을 의미합니다 그리고 당신은 모든 경우에 적용되지 않습니다 . 이것은 check 함수의 정의에서 두 번 발생합니다. 두 번째 매개 변수는 n:nx 패턴과 일치하지만 [] 패턴과는 일치하지 않습니다. 따라서 두 번째 인수가 빈 목록 일 수있는 경우는 다루지 않습니다. 마찬가지로 네 번째 인수를 (l:ls, r:rs)과 대조하여 쌍 요소 중 하나가 빈 목록 일 가능성을 고려하지 않습니다.

그래서 오류를 일으킬 무슨 일이 일어나고 있는지 당신이 readword에서 check를 호출 할 때 하나 sNum이 비어 있거나 tape의 목록 중 하나가 비어 있다는 것입니다.

+0

대단히 감사합니다. 지금은 차기라고 생각하지 않았습니다. – user23012