closure(R)(X,Y) :- R(X,Y). closure(R)(X,Y) :- R(X,Z), closure(R)(Z,Y). |
HiLog can also be used with tabling, so that the program above can also be written as:
:- hilog closure. :- table apply/3. closure(R)(X,Y) :- R(X,Y). closure(R)(X,Y) :- closure(R)(X,Z), R(Z,Y). |