List1=[(x,1),(y,1),(z,1)]
I\'m attempting to split this list:
into two lists:
List3=[x,y,z]
List4=[1,1,1]
So
You're matching the tuple as a whole, rather than it's component parts.
You should match on [(X1,Y1)|XS]
, instead of [X|XS]
and [Y|Ys]
.
splt([],[],[]).
splt([(X1,Y1)|Xs],[X1|T1],[Y1|T2]):-
splt(Xs,T1,T2).
Here the first term is used as input, the second and third as output.
Ideone example, using SWI-Prolog, here.