Isn’t that very complicated? I came to this:
Click to see code
list_difference(L, T) :-
L == T,
!,
is_of_type(list_or_partial_list, L).
list_difference(DL, T) :-
nonvar(DL),
DL = [_|L],
list_difference(L, T).
The only minor problem might be that this loops if the first argument is a cyclic list, so you may want a layout around it using ‘$skip_list’ to verify this isn’t the case. This wrapper may also be used to test for the really common case where the first argument is a list for which the tail is a variable that is the second argument.