I want to replace b,c
with x,y,z
in a list in Prolog. I have a list [a,b,c,d,e,f]
and result will be [a,x,y,z,d,e,f]
. How can I write this in Prolog?
replace([],_,[]).
replace([x|T1],Var,[Y|T2]):-
member(X=Y,var),
!
; X=Y
),
replace(T1,Var,T2).
-? replace([a,b,c,d,e,f],[b,c=x,y,z],R).