这是我想要得到的序言输出:
?-mill(try(a,b,c,d,e),R).
R = (e:-c) ;
使用下面的代码,我得到数字输出。我怎样才能得到(e:-c)
输出,而不是他们的列表位置编号?
?-mill(try(a,b,c,d,e),R).
R = (5:-3) ;
代码:
try(-,+,+,+,+).
try(-,-,+,+,+).
try(+,+,+,+,+).
try(+,+,-,-,-).
try(+,-,-,+,-).
construct(X, Y):-
functor(X,F,N), functor(Y,F,N).
row_number(X, Y):-
findall(a, X, List), length(List, Y).
reason(Table,A,B):-
calc(Table,A,+,PA),
calc(Table,B,+,PB),
calc(Table,A,+,B,+,PP),
calc(Table,A,+,B,-,PM),
PA=PB,
PM=0.
calc(Table,Column,Body,Number):-
construct(Table,Var),
arg(Column,Var,Body),
row_number(Var,Number).
calc(Table,A,Abody,B,Bbody,Number):-
construct(Table,Var),
arg(A,Var,Abody),
arg(B,Var,Bbody),
row_number(Var,Number).
mill(Table,B:-A):-
functor(Table,_,B),
row_number(reason(Table,A,B),1),
reason(Table,A,B).