This Commented CUE demonstrates how to include elements in a list based on some testable condition.
example.cue
package example
#a: "yes"
A: [
1,
2,
// Include a single element using this form:
if #a == "yes" {
3
},
// Include multiple elements using this form,
// which only tests the condition once:
if #a == "yes" for e in [
4,
5,
6,
] {e},
]
TERMINAL
$ cue export
{
"A": [
1,
2,
3,
4,
5,
6
]
}