I'm a beginner in Prolog and I have two make tuples out of two lists using recursion. For example, func ([1, 2, 3], [4, 5, 6]) should output [(1, 4), (1,5), (1,6), (2, 4), (2, 5), (2, 6), (3, 4), (3 ,5), (3, 6)]. I have the following code:
func([],_,[]).
func([X|T1],Y,[Z|W]):-
match(X,Y,Z),
func(T1,Y,W).
match(X,[Y],[(X,Y)]).
match(X,[Y|T],[(X,Y)|Z]) :-
match(X,T,Z).
But my output for func([1,2,3],[4,5,6],X) is X = [[(1, 4), (1, 5), (1, 6)], [(2, 4), (2, 5), (2, 6)], [(3, 4), (3, 5), (3, 6)]].
How can I get rid of the extra square brackets in the middle of my output? I've tried playing with the parenthesis and brackets in both of my functions, but I can't figure it out.