Using SWI-Prolog's listing predicate (or SICStus' predicate in its list library), we have:
lists:subtract([], _, []) :- !.
lists:subtract([A|C], B, D) :-
memberchk(A, B), !,
subtract(C, B, D).
lists:subtract([A|B], C, [A|D]) :-
subtract(B, C, D).
which does this successfully:
?- subtract([2,3,4,5],[3,4],X).
X = [2, 5].
BUT, what if I want to do:
?- new_subtract([2,3,4,5],[3,X],Y).
X = [3, 2],
X = [3, 4],
X = [3, 5],
Y then has three solutions by taking the three X solutions from [2,3,4,5].
However, subtract/2 doesn't allow for this.
I've been trying to solve this for ages by taking the cuts (!)s out of the built in predicate's body to try and get it to backtrack and find all the solutions.