2019-01-15 14:51:21 -05:00
|
|
|
---
|
2023-09-15 10:03:23 -04:00
|
|
|
sidebar_label: setintersection
|
2019-01-15 14:51:21 -05:00
|
|
|
description: |-
|
|
|
|
|
The setintersection function takes multiple sets and produces a single set
|
|
|
|
|
containing only the elements that all of the given sets have in common.
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# `setintersection` Function
|
|
|
|
|
|
|
|
|
|
The `setintersection` function takes multiple sets and produces a single set
|
|
|
|
|
containing only the elements that all of the given sets have in common.
|
|
|
|
|
In other words, it computes the
|
2021-12-14 21:41:17 -05:00
|
|
|
[intersection](https://en.wikipedia.org/wiki/Intersection_\(set_theory\)) of the sets.
|
2019-01-15 14:51:21 -05:00
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
|
setintersection(sets...)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
> setintersection(["a", "b"], ["b", "c"], ["b", "d"])
|
|
|
|
|
[
|
|
|
|
|
"b",
|
|
|
|
|
]
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The given arguments are converted to sets, so the result is also a set and
|
|
|
|
|
the ordering of the given elements is not preserved.
|
|
|
|
|
|
|
|
|
|
## Related Functions
|
|
|
|
|
|
2024-04-24 07:24:30 -04:00
|
|
|
* [`contains`](../../language/functions/contains.mdx) tests whether a given list or set contains
|
2019-01-15 14:51:21 -05:00
|
|
|
a given element value.
|
2024-04-24 07:24:30 -04:00
|
|
|
* [`setproduct`](../../language/functions/setproduct.mdx) computes the _Cartesian product_ of multiple
|
2019-01-15 14:51:21 -05:00
|
|
|
sets.
|
2024-04-24 07:24:30 -04:00
|
|
|
* [`setsubtract`](../../language/functions/setsubtract.mdx) computes the _relative complement_ of two sets
|
|
|
|
|
* [`setunion`](../../language/functions/setunion.mdx) computes the _union_ of
|
2019-01-15 14:51:21 -05:00
|
|
|
multiple sets.
|