First of all, I am completely a beginner at Prolog.
I am trying to compare each element of a list with each element of another list. By compare, I mean sending these 2 elements to a predicate(conflicts) I wrote. So far, I got this:
%iterate over the first list
cmp_list([],_,_).
cmp_list([X|Y],[A|B],Result):-
cmp_list_inner(X,[A|B],Result),
cmp_list(Y,[A|B],Result).
%iterate over the second list
cmp_list_inner(_,[],_).
cmp_list_inner(X,[A|B],S):-
not(conflicts(X,A)), %compare
cmp_list_inner(X,B,[X-A|S]).%if okay, add their combination, i.e X-A to the main list which will be returned
The predicate cmp_list stands for the recursion of outer list, whereas the one with inner stands for inner list. cmp_list(firstlist, secondlist, new list after the combination which will be returned.)
This doesn't work! Even though it adds the values for a single element in the first value to the main list, it doesn't append the second comparison(for the second element in the first list) to the main list which will be returned. Result should be in the form of: [X1-Y1], [X1-Y2], [X2-Y1], [X2-Y2].... where Xs are from the first list and Ys are from the second list.
Any help would be appreciated. Thanks!