扫描序言中的列表
我想扫描 Prolog 中的列表。 特别是,我想编写一个谓词 scan_list (list),我想让它检查当前元素是否是正整数,如果是则打印它。
谢谢。
I want to scan a list in Prolog.
In particular, I want to write a predicate scan_list (list), and I want to make it check to see if the current element is a positive integer and if so print it.
Thank's.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果这是家庭作业,请放心,学习任何编程语言的唯一方法就是练习并思考作业。然而,这里有一个版本可能是您想要的
它的工作原理如下:
If this is homework, be assured that the only way to learn any programming language is to practice it and think about the assignments. However, here is a version that might be, what you want
It works like that:
在 SWI-Prolog 中有
include/3
,例如您可以编写(警告:此特定代码接受的数字多于正整数。)
In SWI-Prolog there is
include/3
, e.g. you can write(Warning: this particular code accepts more numbers than positive integers.)