Prolog:子句在源文件中不在一起 [英] Prolog: Clauses are not together in source-file

查看:62
本文介绍了Prolog:子句在源文件中不在一起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码:

% Family tree
female(pen).
male(tom).
male(bob).
female(liz).
female(pat).
female(ann).
male(jim).

parent(pam, bob).
parent(tom, bob).
parent(tom, liz).
parent(bob, ann).
parent(bob, pat).
parent(pat, jim).

我收到此错误:

Warning: Clauses of female/1 are not together in source-file
Warning: Clauses of male/1 are not together in source-file

这个错误的目的是什么?
我的意思是,文件确实编译并运行得很好,我知道错误的含义.但为什么呢?
这只是为了强制执行最佳实践的通知吗?

What is the purpose of this error?
I mean, file does compile and run just fine and I am aware of the meaning of the error. But why?
Is this just a notice to enforce best practice?

我对逻辑编程很陌生.
谢谢!

I am very new to logic programming.
Thanks!

推荐答案

正确,这是一个强制执行最佳实践的警告,即将所有相关子句放在源文件中.除此之外,源文件中子句彼此的接近程度无关紧要,只要它们的相对顺序不改变即可.

Correct, this is a warning to enforce best practices, which is to put all related clauses together in the source file. Other than that, the proximity of clauses to each other in the source file does not matter, as long as their relative order does not change.

这篇关于Prolog:子句在源文件中不在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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