github.com/hugorut/terraform@v1.1.3/website/docs/language/functions/setsubtract.mdx (about) 1 --- 2 page_title: setsubtract - Functions - Configuration Language 3 description: |- 4 The setsubtract function returns a new set containing the elements 5 from the first set that are not present in the second set 6 --- 7 8 # `setsubtract` Function 9 10 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 11 [relative complement](https://en.wikipedia.org/wiki/Complement_\(set_theory\)#Relative_complement) of the second set. 12 13 ```hcl 14 setsubtract(a, b) 15 ``` 16 17 ## Examples 18 19 ``` 20 > setsubtract(["a", "b", "c"], ["a", "c"]) 21 [ 22 "b", 23 ] 24 ``` 25 26 ### Set Difference (Symmetric Difference) 27 28 ``` 29 > setunion(setsubtract(["a", "b", "c"], ["a", "c", "d"]), setsubtract(["a", "c", "d"], ["a", "b", "c"])) 30 [ 31 "b", 32 "d", 33 ] 34 ``` 35 36 ## Related Functions 37 38 * [`setintersection`](/language/functions/setintersection) computes the _intersection_ of multiple sets 39 * [`setproduct`](/language/functions/setproduct) computes the _Cartesian product_ of multiple 40 sets. 41 * [`setunion`](/language/functions/setunion) computes the _union_ of 42 multiple sets.