tags:

views:

163

answers:

0

Hey.

I have a problem with a problem in Prolog. Here's some of the code I use.

has_same_elements([X|_],Y) :-
    permutation(X,Xnew),        
    member(Xnew,Y), !.
has_same_elements([_|Tail],Y) :-    has_same_elements(Tail,Y).

This gets two lists of lists as input, and decides whether or not they contain lists with the same elements. E.g. [[1,2],[3,4]] has the same elements as [[2,1],[4,3]]. This works fine.

Now my findall:

findall(V, (verdeling2(S,Perm,V), \+X^(X\=V,verdeling2(S,Perm,X),has_same_elements(X,V))) ,Verd).

All that's important to know is that verdeling2/3 is a clause that returns different lists of lists (as mentioned above), and it's constructed from a permutation of [1,2,3,4,...] Some different outputs of verdeling2/3 (according to the permutation as input) are:

V = [[[1, 2], [3, 4]]] ;
V = [[[2, 1], [3, 4]]] ;
V = [[[2, 3], [1, 4]]] ;
V = [[[2, 3], [4, 1]]] ;
V = [[[1, 3], [2, 4]]] ;
V = [[[3, 1], [2, 4]]] ;
V = [[[3, 2], [1, 4]]] ;
V = [[[3, 2], [4, 1]]] ;
V = [[[1, 3], [4, 2]]] ;
V = [[[3, 1], [4, 2]]] ;
V = [[[3, 4], [1, 2]]] ;
V = [[[3, 4], [2, 1]]] ;
V = [[[1, 2], [4, 3]]] ;
V = [[[2, 1], [4, 3]]] ;
V = [[[2, 4], [1, 3]]] ;
V = [[[2, 4], [3, 1]]] ;
V = [[[1, 4], [2, 3]]] ;
V = [[[4, 1], [2, 3]]] ;
V = [[[4, 2], [1, 3]]] ;
V = [[[4, 2], [3, 1]]] ;
V = [[[1, 4], [3, 2]]] ;
V = [[[4, 1], [3, 2]]] ;
V = [[[4, 3], [1, 2]]] ;
V = [[[4, 3], [2, 1]]] ;

Now I'd want something that gives me an overview of all lists that don't contain the same elements (using has_same_elements). I thought my use of findall should do the trick, but it returns full packet, instead of filtering the ones I don't want.