I\'m trying to wrap my head around this:
r([], _, []). r([a(H,_)|T], a(H,X), [a(H,X)|T]). r([a(H,V)|T], a(I,L), [a(H,V)|R]) :- H \\= I, r(T, a(I,L), R