I have to write the tr rule to translate all occurrences of a list element value to another value.
tr(A,B,L,M)
if list M is the same as list L, except that every occurrence of A in L is replaced by B. For instance:
?- tr(1,2,[1,4,1,5],L).
L = [2, 4, 2, 5].
What I have so far:
tr(_, _, [], []).
tr(O, R, [O|T], [R|T2]) :- tr(O, R, T, T2).
tr(O, R, [H|T], [H|T2]) :- H \= O, tr(O, R, T, T2).
Is there a way to replace the tr(_, _, [], []).
with tr(A,B,L,M).
so that it uses the letters A,B,L,M
?