Simplified Common Lisp reference
set-difference
Symbol class: Conses, Lists and related functions
Syntax:
Symbol type: function
set-differencelist1list2key(keyword)test(keyword) => list
Argument description:
list1 a list
list2 a list
key function for extracting value before test
test function key and item comparison

SET-DIFFERENCE function computes set difference, that is a list of elements that appear in list1 but do not appear in list2. Test argument specifies comparison operator. Default comparison operator is EQL. Key argument specifies function for extracting relevant value from list items. Default key is IDENTITY. Resulting item order is not specified. See also SET-EXCLUSIVE-OR, UNION and INTERSECTION.

(set-difference '(a b c) '(b c d)) => (A)
(set-difference '("a" "b" "c") '("b" "c" "d")) => ("c" "b" "a")
(set-difference '("a" "b" "c") '("b" "c" "d") :test #'equal) => ("a")
(set-difference '((a . 2) (b . 3) (c . 1)) '((b . 1) (c . 2) (d . 4)) :test #'equal) => ((C . 1) (B . 3) (A . 2))
(set-difference '((a . 2) (b . 3) (c . 1)) '((b . 1) (c . 2) (d . 4)) :key #'car) => ((A . 2))
(set-difference '((a . 2) (b . 3) (c . 1)) '((b . 1) (c . 2) (d . 4)) :key #'cdr) => ((B . 3))
Function indexFull documentation for set-difference (HyperSpec)