Solution:
% When down to one if A is member of M the result
% is empty list
function([A],M,[]):-
member(A,M).
% else A is in the result
function([A],M,[A]):-
\+member(A,M).
% when more than one, make function of tail and simply
% return L1 because H is member of M
function([H|T],M,L1):-...