I am trying to write a predicate that follows some simple conditions. It should take 2 lists and 2 variables and should return true if the first variable is located at the same position in the first list as the second variable is located in the second list. I did one part but I am struggling to get the other part working. This is what I have done so far, but in some way I need to check the rest of the positions in the list.
position([A|_],[B|_],Var1,Var2):-
A = Var1,
B = Var2.
I want for example to be able to write like this:
position([x,y,z],[1,2,3],z,3).
true .
Thanks in advance.
EDIT
I have tried and what I write keep giving me false, I thought this would work but it doesn't...:
position([A|C],[B|D],Var1,Var2):-
A = Var1,
B = Var2,
position(C,D,Var1,Var2).
Not sure why this doesn't work..