I know how to remove the first occurence of an element.
For example, we have a list: [a,a,a,b,b,b,c,c,c,d,d,d].
del(_, [], []).
del(X, [X|T], T).
del(X, [H|T], [H|R]) :- del(X, T, R).
?- del(a, [a,a,a,b,b,b,c,c,c,d,d,d], X)
From this code I will get the result [a,a,b,b,b,c,c,c,d,d,d].
But how should I write the code to get [a,a,b,b,c,c,d,d] in result?