158. a.buckets() is the one domain-keyed grouping (2026-11-21)
- Decision.
bucketsis a method on any keyed table:a.buckets()maps each valuekto the keysiwitha[i] == k, keyed by the value domain ([D]K -> [K]List<D>). Group by any domain-valued key witha.map(key).buckets(); an optional table gives aNonebucket, read asb[Some(k)].preimages(the[I]?Vform) is folded in and removed, and the freebuckets(key)becomes the method.a.group(by:)stays the hash-keyed form for keys that are not domains. - Why. The blind dmpg16g2 dream wanted
R.group(pairs) -> [R]List, and its port spent a five-line push loop becausegroup(by:)returns aHashMap. Library results stay in the keys they were given, so a domain-valued key should give a domain-keyed result. Overloadinggroupby whetherKis a domain is out (decision 127: no overloading by type), andbuckets/preimageswere two names for one job. - Reverse. Restore free
buckets(key)andpreimages(self: [I]?V)inspec/std/seq.cpand the callers incorpus/problems/{egoi23p7,dmpg16g2}.