【发布时间】:2017-10-22 13:20:22
【问题描述】:
这里我有一个模块规则列表。
module(oop). % Object Oriented Programming
module(se1). % Software Engineering 1
module(se2). % Software Engineering 2
% etc.
然后我定义了每个模块的先决条件。
require(oop, []). % oop is base module. It doesn't require any other modules.
require(se1, [oop]). % se1 requires oop
require(se2, [se1]). % se2 requires se1
如您所见,se2 需要 se1(直接)和 oop(间接)。
我想定义一个递归遍历列表并将所有需要的模块作为列表返回的函数。
查询:
?- dependent(se2, L).
预期结果:
L = [se1, oop]
如何在 Prolog 中使用递归编写依赖谓词?
非常感谢您的帮助。
【问题讨论】:
-
How can write the dependent function:Prolog没有函数只有谓词...