This prologue outputs what I'm trying to get:
?-mill(try(a,b,c,d,e),R). R = (e:-c) ;
With the code below, I get numerical output. How can I get the output (e:-c) and not their position numbers in the list?
?-mill(try(a,b,c,d,e),R). R = (5:-3) ;
code:
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).