首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Miranda中缺少大小写定义

Miranda中缺少大小写定义
EN

Stack Overflow用户
提问于 2011-11-07 05:22:23
回答 1查看 153关注 0票数 1

当我调用它时,我得到了一个缺失的大小写定义

代码语言:javascript
复制
check c (n:nx) state (l:ls,r:rs)
=true,if((isprefix state c)&(r=n))
=false, otherwise

我已经检查过了,无论我发送什么,它都会自动工作。

这就是我调用它的地方(警告:它现在写得有点糟糕):

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-11-07 05:31:01

缺少大小写定义意味着你正在进行模式匹配,并且你没有覆盖所有大小写。这在check函数的定义中发生了两次:将第二个参数与模式n:nx匹配,但不与模式[]匹配(因此没有涵盖第二个参数可能是空列表的情况)。类似地,您将第四个参数与(l:ls, r:rs)进行匹配,而不考虑这对元素中的任何一个元素可能是空列表的可能性。

导致错误的原因是,当您从readword调用check时,要么sNum为空,要么tape中的某个列表为空。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8030483

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档