I am learning rooPlog and have some list problems. I want to return a list of classes that are prerequisites for the specified class. Here is what I still have ...
prereq(262, 221).
prereq(271, 262).
prereq(331, 271).
prerequisites(A, B) :- not(prereq(A, C)).
prerequisites(A, [C|B]) :- prereq(A, C), prerequisites(C, B).
It works, but adds junk to the end.
?- prerequisites(331, A).
A = [271, 262, 221|_G327] ;
false.
source
share