Disclaimer: This is not an efficient way to do this in eLisp. The effective way is through a hash table with a hash function, but since you asked about lists, here is this:
(defun custom-set-difference (ab) (remove-if
The second is a bit more efficient because it will remove the elements as it does subsequent checks, but the first is shorter and more straightforward.
Also note that lists are not a good representation of sets, because they naturally allow you to repeat. For this purpose, it is better to use hash maps.
user797257
source share