cue: add builtins and and or
These allow computing disjunctions and
conjunctions, for instance resulting from
comprehensions.
Change-Id: I1db6566c9114d70017c923e93f1c1d4091085db9
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/1920
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Marcel van Lohuizen <mpvl@google.com>
diff --git a/doc/ref/spec.md b/doc/ref/spec.md
index 7cacb59..2dbc8ac 100644
--- a/doc/ref/spec.md
+++ b/doc/ref/spec.md
@@ -2251,6 +2251,28 @@
len({a:1, b:2}) 2
```
+### `and`
+
+The built-in function `and` takes a list and returns the result of applying
+the `&` operator to all elements in the list.
+It returns top for the empty list.
+
+Expression: Result
+and([a, b]) a & b
+and([a]) a
+and([]) _
+
+### `or`
+
+The built-in function `or` takes a list and returns the result of applying
+the `|` operator to all elements in the list.
+It returns bottom for the empty list.
+
+Expression: Result
+and([a, b]) a | b
+and([a]) a
+and([]) _|_
+
## Cycles