I'm trying to make my code more dynamic. I have a file with the following contents:
a(b1, c1, d1).
a(b2, c2, d2).
a(b3, c3, d3).
And as I find all b1
, I make a list like this:
[b1, b2, b3].
When the arity changes in the file, for example, when a(b1,c1,d1)
becomes a(b1,c1,d1,e1)
, my code does not work. Is there a way to solve this problem? I'm using SWI-Prolog.
start :-
consult('file.pl'),
solve(L1, L2, L3),
list_to_set(L1, X),
write(X).
solve(L1, L2, L3):-
findall(First, data(First, _, _), L1),
findall(Second, data(_, Second, _), L2),
findall(Third, data(_, _, Third), L3).