Associative Lists
CUE does not have a set
type.
The proposed method is to use
associative lists.
An associative list is a list that defines a key for each of its values, effectively turning it into a map. In CUE terms, elements with the same key are unified and collapsed onto a single element as if it were a struct.
In the following, we have
original.cue
contains two lists we’d like to unifyresults.cue
contains the desired resultssyntax.cue
contains the CUE to make this happen
The syntax uses the @.field
to define the key
used to determine which values should be unified
to produce the result.
You can find more details on GitHub:
Today, you can use structs to achieve unique elements to or from a list. See the unique list pattern for more details