I have a list and a list of lists:
A = [1,2,4,5]
L = [[1,2,5],[3,4,5]]
If A contains the same elements as one of the lists, I want it to return true. As A contains the same elements (1,2,5) as the first list in L ([1,2,5]), it should return true even though there's one element in A that isn't in the first list in L.
I've tried using a couple of predicates supplied in the answer of a similar question in order to solve this:
p(X):- findall( Y, (member(Y,X), \+ have_common_element(X,Y) ), [_]).
have_common_element(A,B):- member(X,A), memberchk(X,B).
However the following query will return false:
p([[[1,2,5],[3,4,5]],[1,2,4,5]]).
I understand that this is because there is an element in A (4) that isn't in the first list of L, although I'm having difficulty figuring out how to extend the predicates to have the query return true.
Would it be possible to extend these predicates so that true will be returned even with the additional (and non-mutual) element included?