0
votes

Write a program in Prolog to implement vanish(R,L,N) where R denotes the element whose all occurrences has to be remove from list L to obtain list N.

1
I’m voting to close this question because this is a boot camp Prolog exercise; some effort is required.David Tonhofer

1 Answers

0
votes

This should work :

vanish(_,[],[]).
vanish(E,[E|Ls],N) :- vanish(E,Ls,N).
vanish(E,[L|Ls],[L|Ns]) :- L\=E, vanish(E,Ls,Ns).