Prolog 执行查询

发布于 2024-10-05 20:57:34 字数 702 浏览 0 评论 0原文

这直接来自在线教程,我得到了一个自上而下的设计错误,有帮助吗?

employee(193,'Jones','John','173 Elm St.','Hoboken','NJ',
                                          12345,1,'25 Jun 93',25500).
employee(181,'Doe','Betty','11 Spring St.','Paterson','NJ',
                                          12354,3,'12 May 91',28500).
employee(198,'Smith','Al','2 Ace Ave.','Paterson','NJ',
                                          12354,3,'12 Sep 93',27000).

给定这些基本关系(也称为外延关系),我们可以使用 Prolog 过程定义来定义其他关系,以回答我们可能对数据产生的问题。例如,我们可以定义一个新关系,其中包含所有收入超过 28,000 美元的员工的姓名:

well_paid_emp(First,Last) :-
    employee(_Num,Last,First,_Addr,_City,_St,_Zip,_Dept,_Date,Sal),
    Sal > 28000.

This is directly from a tutorial online, and I get a top down level design error, help?

employee(193,'Jones','John','173 Elm St.','Hoboken','NJ',
                                          12345,1,'25 Jun 93',25500).
employee(181,'Doe','Betty','11 Spring St.','Paterson','NJ',
                                          12354,3,'12 May 91',28500).
employee(198,'Smith','Al','2 Ace Ave.','Paterson','NJ',
                                          12354,3,'12 Sep 93',27000).

Given these basic relations (also called extensional relations), we can define other relations using Prolog procedure definitions to give us answers to questions we might have about the data. For example, we can define a new relation containing the names of all employees making more than $28,000:

well_paid_emp(First,Last) :-
    employee(_Num,Last,First,_Addr,_City,_St,_Zip,_Dept,_Date,Sal),
    Sal > 28000.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枯寂 2024-10-12 20:57:34

可能您正在使用 Prolog 系统,该系统显示 well_paid_emp/2 的单例警告。

并非所有 Prolog 系统都允许 _作为单例,即在规则中仅出现一次的变量。

It could be that you are using a Prolog system which shows a singleton warning for well_paid_emp/2.

Not all Prolog systems allow _<Capital><Rest> as singletons, i.e. variables that occur only once in a rule.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文