Question: I need help with this question. Please do this in Prolog language Write a program to replaces all occurrences of one item in a list
Write a program to replaces all occurrences of one item in a list with another. It should have four arguments. The list you wish to use. The item to replace. The item to replace it with, and the resulting list. Here are some examples of its behavior ?- replace_all([a, b,a,c,a,d],a,mike, Result). Result [mike,b,nike,c,mike,d] ?- replace all([a,b,a,c,a, d],b, foo, Result). Result [a,foo,a,c,a,d) ?- replace all([a,b,a,c,a, d],prolog,logic,Result) Result [a,b,a,c,a,d
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
