prolog - Error 1, Backtrack Stack Full

后端 未结 2 1030
失恋的感觉
失恋的感觉 2020-12-20 01:32

im trying to write a program in prolog that determine if there is a way from place to place. these are the relations:

road(ny,florida).
road(washington,flori         


        
2条回答
  •  心在旅途
    2020-12-20 02:19

    First, we need a symmetric definition:

    :- meta_predicate symm(2, ?,  ?).
    
    symm(P_2, A, B) :-
       call(P_2, A, B).
    symm(P_2, A, B) :-
       call(P_2, B, A).
    

    Now, using closure0/3

    there_is_way(A, B) :-
       closure0(symm(road), A, B).
    

提交回复
热议问题