2020-02-06 18:49:11 +01:00
---
2021-11-23 00:57:25 +01:00
layout: "language"
page_title: "setsubtract - Functions - Configuration Language"
sidebar_current: "docs-funcs-collection-setsubtract"
2020-02-06 18:49:11 +01:00
description: |-
The setsubtract function returns a new set containing the elements
from the first set that are not present in the second set
---
# `setsubtract` Function
The `setsubtract` function returns a new set containing the elements from the first set that are not present in the second set. In other words, it computes the
2021-11-23 00:57:25 +01:00
[relative complement ](https://en.wikipedia.org/wiki/Complement_(set_theory )#Relative_complement ) of the second set.
2020-02-06 18:49:11 +01:00
```hcl
setsubtract(a, b)
```
## Examples
```
> setsubtract(["a", "b", "c"], ["a", "c"])
[
"b",
]
```
### Set Difference (Symmetric Difference)
```
> setunion(setsubtract(["a", "b", "c"], ["a", "c", "d"]), setsubtract(["a", "c", "d"], ["a", "b", "c"]))
[
"b",
"d",
]
```
2021-11-23 00:57:25 +01:00
2020-02-06 18:49:11 +01:00
## Related Functions
2021-11-23 00:57:25 +01:00
* [`setintersection` ](./setintersection.html ) computes the _intersection_ of multiple sets
* [`setproduct` ](./setproduct.html ) computes the _Cartesian product_ of multiple
2020-02-06 18:49:11 +01:00
sets.
2021-11-23 00:57:25 +01:00
* [`setunion` ](./setunion.html ) computes the _union_ of
2020-02-06 18:49:11 +01:00
multiple sets.