是否可以在Prolog中写一个空列表作为差异列表? [英] Is it possible to write an empty list as a difference list in Prolog?

查看:81
本文介绍了是否可以在Prolog中写一个空列表作为差异列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于像我这样的Prolog初学者来说,空列表很奇怪.我会说不可能写一个空列表[]作为差异列表T1-T2,就像不可能写一个原子作为差异列表一样.但是,我猜想要使用递归,必须存在一种在差异列表设置中使用[]的方法.我为此提供了Google服务,但找不到答案,而Bratko(用于AI的Prolog编程)只是短暂地触及了这个主题.

Empty lists are ... strange, to a Prolog beginner like myself. I would say that it isn't possible to write an empty list [] as a difference list T1-T2 just as it isn't possible to write an atom as a difference list. However, I would guess that to use recursion, there must be a way to use [] in a difference list setting. I have Google'd for this but I cannot find an answer, and Bratko (Prolog Programming for AI) only briefly touches the subject.

那么,是否有可能在Prolog中写一个空列表作为差异列表,如果有的话,它将如何以及何时会有用?

So, is it possible to write an empty list as a difference list in Prolog, if so how and when would it be useful?

推荐答案

了解此主题的问题通常是由于使用了误导性术语.

Problems with understanding this topic are typically due to using misleading terminology.

tutorial.pdf 中的建议 pap95.pdf ,例如使用 list  ; difference 或简单地 difference .

As recommended in tutorial.pdf and especially pap95.pdf, use for example list difference or simply difference.

教学初学者Prolog 包含与此相关的原因.

Section 5 of Teaching beginners Prolog contains relevant reasons for this.

空白列表由原子 []唯一表示.

The empty list is uniquely denoted by the atom [].

请注意,列表差异始终意味着对两个列表进行推理,由于单个列表和多个列表之间存在这种绝对差异,因此您最好能找到一些对应或类比,但是在空列表和列表差异之间不相同.

Note that a list difference always means reasoning about two lists, and due to this categorical difference between a single and multiple lists, you can at best find some correspondence or analogy, but not identity between the empty list and a list difference.

我完全支持以上论文中表达的观点,即至少应该首先关注使用DCG .明确地对差异进行推理将在以后自然而然地传给您.

I completely support the view expressed in the paper above that you should focus on using DCGs, at least at first. Reasoning about differences explicitly will come naturally later to you.

这篇关于是否可以在Prolog中写一个空列表作为差异列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆