list - Prolog file manipulation problem -
i use swi prolog , code this. read data predicate file , arity count can change. how can generalize it. example, if data(a1,b1,c1) writes in file, how can find solution? have idea?
> basla:-consult('test.pl'), > answer(l1,l2,l3,l4,l5), > list_to_set(l1, x), > > write(x). > answer(l1,l2,l3,l4,l5):- > findall(first, data(first,_,_,_,_),l1), > findall(second, data(_,second,_,_,_),l2), > findall(third, data(_,_,third,_,_),l3).
if arity of predicate seems change, it's better make arity 1 , give list argument. findall
queries can extended call nth1
or nth0
.
Comments
Post a Comment