i write this programm for give me this result : "X=john" "Y=jane"
likes(john,mary).
likes(mary,jane).
likes(l,k).
likes(X,Y) :- likes(X,Z), likes(Z,Y).
but if run this programm such that this result: i think the programm get in loop ! i want to stop after true answer !
1 ?- likes(X,Y).
X = john,
Y = mary ;
X = mary,
Y = jane ;
X = l,
Y = k ;
X = john,
Y = jane ;
ERROR: Out of local stack
i have the error ! how solving this problem ?
by debugging :
[debug] 3 ?- likes(john,Y).
T Call: (6) likes(john, _G2162)
T Exit: (6) likes(john, mary)
Y = mary ;
T Redo: (6) likes(john, _G2162)
T Call: (7) likes(john, _G2267)
T Exit: (7) likes(john, mary)
T Call: (7) likes(mary, _G2162)
T Exit: (7) likes(mary, jane)
T Exit: (6) likes(john, jane)
Y = jane ;
T Redo: (7) likes(mary, _G2162)
T Call: (8) likes(mary, _G2267)
T Exit: (8) likes(mary, jane)
T Call: (8) likes(jane, _G2162)
T Call: (9) likes(jane, _G2267)
T Call: (10) likes(jane, _G2267)
T Call: (11) likes(jane, _G2267)
T Call: (12) likes(jane, _G2267)
T Call: (13) likes(jane, _G2267)
T Call: (14) likes(jane, _G2267)
T Call: (15) likes(jane, _G2267)
and so on .. why likes(jane, _G2267) ??????