Self-Test 10

Unification and equality again
 
This question includes a partial program. You are advised to copy and paste this into a file. You should develop your solution on a machine and test it before looking at the solution.
 
  The procedure for deleting all elements from a list is given as:
 
 

     % 1 terminating condition
     delete_all(_, [], []).
     % 2 recursive - Elem matches head
     delete_all(Elem, [Elem|Tail1], Tail2) :-
          delete_all(Elem, Tail1, Tail2).
     % 3 recursive - Elem doesn't match head
     delete_all(Elem, [Head|Tail1], [Head|Tail2]) :-
          \+ (Elem = Head),
          delete_all(Elem, Tail1, Tail2).
   
  Convert this code into delete_all_eq/3, which uses strict equality to test the relationship between Elem and the head of the second argument.
   
 
     | ?- delete_all_eq(a, [a,b,a,b], List).

     List = [b,b] ? ;

     no
     | ?- delete_all_eq(a, [a,b,Var,b], List).

     List = [b,Var,b] ? ;

     no