shared/sets.bend
1# Set helpers. Base's Set.has gives the set back beside its answer; these give the answer alone.
2import Base
3
4def has(set: Set(), key: String) -> Bool:
5 Pair.snd(Set(), Bool, Set.has(set, key))
6
7# Whether one of `keys` is in `set`, or `found`.
8def has_any(keys: List<&2, String>, +set: Set(), found: Bool) -> Bool:
9 match keys found:
10 case _ True{}:
11 True{}
12 case Nil{} False{}:
13 False{}
14 case Con{key, rest} False{}:
15 has_any(rest, set, has(set, key))