Exists#
The e.exists(x, p) macro tests whether predicate p is true for any element x in collection e.
Lists#
Returns true if the predicate is true for at least one element.
An empty list returns false.
Maps#
When applied to a map, exists iterates over the keys.
// input: scores = {"alice": 95, "bob": 72}
scores.exists(name, scores[name] >= 90)
// result: true (bool)
An empty map returns false.
Membership#
For clarity, use in rather than exists for membership checks.
The following two examples are equivalent.
Short-circuit evaluation#
Evaluation stops at the first true result.
The first element produces true so evaluation stops before reaching 0.