The lists module provides the subtract function, which takes two list and returns a new copy of the first list, such that the first occurrence of each element of the second list is removed. For example:
1> A = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16].
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
2> B = [2,4,6,8,9,10,12,14,15,16].
[2,4,6,8,9,10,12,14,15,16].
3> lists:subtract(A,B).
[1,3,5,7,11,13]
Note: Erlang provides native list operators for concatentation (++) and subtraction (--). The subtraction operator provides the same functionality as the lists:subtract function: