# complement function

The elements of a list that are in none of the others.

## How to write it

### complement(all, others, ...)

**all**

The list to take elements from. Takes a list.

**others**

A list of elements to leave out. Takes a list.

## Examples

- $\displaystyle \operatorname{complement}(\left[ 1, 2, 3 \right], \left[ 2 \right]) = \left[ 1, 3 \right]$

  `complement([1, 2, 3], [2])`

  In the solver, `complement([1, 2, 3], [2])` gives `[1, 3]`.

  [Open in the solver](https://hilberon.com/?q=complement%28%5B1%2C%202%2C%203%5D%2C%20%5B2%5D%29)

## Related functions

- [constant_array](https://hilberon.com/library/constant_array)

  A list of copies of a value.
- [apply](https://hilberon.com/library/apply)

  Replace the head of an expression, or the brackets of a list, with a function.
- [count](https://hilberon.com/library/count)

  How many elements of a list equal a value.
- [append](https://hilberon.com/library/append)

  A list with an element added at the end.
- [dimensions](https://hilberon.com/library/dimensions)

  The size of a list or a matrix, level by level.
- [accumulate](https://hilberon.com/library/accumulate)

  Running totals of a list.

---
Source: https://hilberon.com/library/complement
