简体   繁体   English

定义相同谓词三遍

[英]Defining the same predicate three times

I am new to Prolog and I had a question about defining predicates. 我是Prolog的新手,我对定义谓词有疑问。 I am reading some code where the same fact is defined more than once: 我正在阅读一些代码,其中多次定义了相同的事实:

sister(jenny, sarah).
sister(jenny, sarah).
sister(jenny, sarah).

From what I understand, this is a fact representing that jenny and sarah are sisters but this code is repeated three times. 据我了解,这是一个事实,表示詹妮和莎拉是姐妹,但此代码重复了三遍。 What significance does this have? 这有什么意义?

sister(jenny, sarah).
sister(jenny, sarah).
sister(jenny, sarah).

What significance does this have? 这有什么意义?

None. 没有。 It is a mistake. 这是一个错误。


With regards to 关于

this is a function 这是一个功能

Prolog does not have functions, only predicates. Prolog没有功能,只有谓词。

With regards to 关于

same predicate three times 同一谓词三遍

Those are not predicates, those are facts because they have no :- or body . 这些不是谓词,这些是事实,因为它们没有:-body

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM