首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >需要解释的剪辑编程

需要解释的剪辑编程
EN

Stack Overflow用户
提问于 2017-09-19 01:45:40
回答 1查看 305关注 0票数 0

1)如果用户输入的不是yes/no,我需要一种方法来重复这个问题。

2)我需要一种允许剪辑接受小写和大写字母的方法。

我通过谷歌搜索找到了这个样本,但我不太确定它在某些行上是如何工作的。有人能给我解释一下这是怎么工作的吗?或者有一个更好的方法来做我需要的两件事。

代码语言:javascript
运行
复制
(deffunction ask-question (?question $?allowed-values)
   (printout t ?question)
   (bind ?answer (read))
   (if (lexemep ?answer) 
       then (bind ?answer (lowcase ?answer)))
   (while (not (member ?answer ?allowed-values)) do
      (printout t ?question)
      (bind ?answer (read))
      (if (lexemep ?answer) 
          then (bind ?answer (lowcase ?answer))))
   ?answer)

(deffunction yes-or-no-p (?question)
   (bind ?response (ask-question ?question yes no y n))
   (if (or (eq ?response yes) (eq ?response y))
       then yes 
       else no))
EN

回答 1

Stack Overflow用户

发布于 2017-09-19 06:16:55

ask-question函数的伪代码:

代码语言:javascript
运行
复制
Print the question.
Get the answer.

If 
  The answer is a symbol or string
Then 
  Convert the answer to lower case.
End if

While the answer is not one of the allowed values

   Print the question.
   Get the answer.

   If 
     The answer is a symbol or string
   Then 
     Convert the answer to lower case.
   End if

End while

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

https://stackoverflow.com/questions/46285344

复制
相关文章

相似问题

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