Here I have a list of modules rule.
module(oop). % Object Oriented Programming
module(se1). % Software Engineering 1
module(se2). % Software Engineering 2
% etc.
Then I defined the prerequisites for each module.
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
As you can see, se2
requires se1 (directly) and oop (indirectly).
I would like to define a function which goes through the list recursively and return all the required modules as a list.
Query:
?- dependent(se2, L).
Expected Result:
L = [se1, oop]
How can I write the dependent predicate in Prolog using recursion?
Thank you very much for your help.
How can write the dependent function
: Prolog has no functions only predicates... – coder