some help with recursion again



Hello to every reader,

this is for sure a newbiequestion, but I've no idea about a solution:
imagine, i have the data collection

tupel([[0,0],[0,0]]).
tupel([[1,0],[1,0]]).
tupel([[1,0],[1,1]]).
tupel([[1,1],[0,0]]).

and I'd like to have a predicate "fkt/1" with the results
[[[1, 1], [0, 0]], [[1, 0], [1, 0]], [[0, 0], [0, 0]]]
and [[[1, 1], [0, 0]], [[1, 0], [1, 1]], [[0, 0], [0, 0]]].

In words, if you imagine tupel([X,Y]) as a pair (x, y),
I want the resulting list to represent a (partial) function.
To make things clear to myself, I wrote my wish down as a goal:

fkt(ErgList) :-
List = [],
tupel([A1|A2]),
not_member([A1|_], List),
List1 = [[A1|A2]|List],
tupel([B1|B2]),
not_member([B1|_], List1),
List2 = [[B1|B2]|List1],
tupel([C1|C2]),
not_member([C1|_], List2),
ErgList = [[C1|C2]|List2].

As to be seen, there is an iteration in and I wonder how could I express this recursively (this would be really helpful, as the database of tupels could change), but I do not have any idea until now.

Thanks in advance for any hints,


Best Regards,

alexander sauerbier
-------------------------------
(ps:
yes, there is another error left, because I get 12 solutions instead of 2 - but this will be the next problem.)


.