github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/website/content/docs/job-specification/hcl2/functions/collection/setintersection.mdx (about)

     1  ---
     2  layout: docs
     3  page_title: setintersection - Functions - Configuration Language
     4  description: |-
     5    The setintersection function takes multiple sets and produces a single set
     6    containing only the elements that all of the given sets have in common.
     7  ---
     8  
     9  # `setintersection` Function
    10  
    11  The `setintersection` function takes multiple sets and produces a single set
    12  containing only the elements that all of the given sets have in common.
    13  In other words, it computes the
    14  [intersection](<https://en.wikipedia.org/wiki/Intersection_(set_theory)>) of the sets.
    15  
    16  ```hcl
    17  setintersection(sets...)
    18  ```
    19  
    20  ## Examples
    21  
    22  ```shell-session
    23  > setintersection(["a", "b"], ["b", "c"], ["b", "d"])
    24  [
    25    "b",
    26  ]
    27  ```
    28  
    29  The given arguments are converted to sets, so the result is also a set and
    30  the ordering of the given elements is not preserved.
    31  
    32  ## Related Functions
    33  
    34  - [`contains`](/docs/job-specification/hcl2/functions/collection/contains) tests whether a given list or set contains
    35    a given element value.
    36  - [`setproduct`](/docs/job-specification/hcl2/functions/collection/setproduct) computes the _Cartesian product_ of multiple
    37    sets.
    38  - [`setunion`](/docs/job-specification/hcl2/functions/collection/setunion) computes the _union_ of
    39    multiple sets.