Question: Write a prolog program for substitute(X,Y,L1,L2), where L2 is the result of substituting Y for all occurrences of X in L1, e.g., substitute(a,x,[a,b,a,c],[x,b,x,c]) is true,
Write a prolog program for substitute(X,Y,L1,L2), where L2 is the result of substituting Y for all occurrences of X in L1, e.g., substitute(a,x,[a,b,a,c],[x,b,x,c]) is true, whereas substitute (a, x, [a,b, a, c] , [a,b ,x, c] ) is false.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
