8.15 List Operations

  1. Expr1 ++ Expr2
  2. Expr1 -- Expr2

The list concatenation operator ++ appends its second argument to its first and returns the resulting list.

The list subtraction operator — produces a list that is a copy of the first argument. The procedure is a follows: for each element in the second argument, the first occurrence of this element (if any) is removed.

Example:

  1. 1> [1,2,3]++[4,5].
  2. [1,2,3,4,5]
  3. 2> [1,2,3,2,1,2]--[2,1,2].
  4. [3,1,2]

Warning

The complexity of A — B is proportional to length(A)*length(B). That is, it becomes very slow if both A and B are long lists.