I need help with understanding how to work with lists like that [a(b,c),a(x,d)] change(S,K,R) changes first list [a,c,b] with values given in second list [c(a,x),c(b,y)]
?- change([a,c,b],[k(a,x),k(b,y)],R).
R = [x,c,y].
% my program but it works with second list that is of wrong list elements type k(a,x) but like [a,x] and works kinda poorly cause return True instead of R= x,c,y, if i print R value it is [y,c,x|_2826] i call my code with ?- change([a,c,b],[a,x,b,y],R).
change([],[],[]):-!.
change([],[],R):-write(R),!.
change([H1|T1],[],[H1|R]):-change(T1,[],R),!.
change([H1|T1],[H2,H3|T2],R) :-
( ( H1==H2 , change(T1,T2,[H3|R]) )
; ( H1\==H2, change(T1,[H2,H3|T2],[H1|R]) )
).