chickadee » srfi-1 » lset-difference

lset-difference = list_1 list_2 ...procedure

Returns the difference of the lists, using = for the element-equality procedure -- all the elements of LIST_1 that are not = to any element from one of the other LIST_I parameters.

The = procedure's first argument is always an element of LIST_1; its second is an element of one of the other LIST_I. Elements that are repeated multiple times in the LIST_1 parameter will occur multiple times in the result. The order in which elements appear in the result is the same as they appear in LIST_1 -- that is, lset-difference essentially filters LIST_1, without disarranging element order. The result may share a common tail with LIST_1. The dynamic order in which the applications of = are made is not specified. The procedure may check an element of LIST_1 for membership in every other list before proceeding to consider the next element of LIST_1, or it may completely compute the difference of LIST_1 and LIST_2 before proceeding to LIST_3, or it may go about its work in some third order.

(lset-difference eq? '(a b c d e) '(a e i o u)) => (b c d)
 
(lset-difference eq? '(a b c)) => (a b c) ; Trivial case