164. Pair<V> is the domain of unordered pairs (2026-11-21)
- Decision.
Pair<V>(spec/std/pair.cp, in the prelude) is a domain of the unordered pairs{lo, hi}of distinct positions ofV.[Pair<V>]Tstores one value per pair, packed, withV.count * (V.count - 1) / 2slots. It walks byhi, then bylo, soread<[Pair<V>]T>()reads a lower triangle without its diagonal. An array over it takes two positions in either order (d[u, v] == d[v, u], trapping whenu == v), andd.symmetric(diag: x)expands it into a[V, V]T. - Why. egoi23p4 (a distance matrix) and cco20p4 (the colour of each road of a complete graph)
give data once per unordered pair, as a lower triangle. Both ports had hand-written readers
that mirrored values into a square matrix or indexed by
max/min. Aread lower_trianglemode was rejected as a one-problem helper. Ragged reads ([i in V][..i]T) describe how the input is written, not what the data is, and still need a mirroring step.Pair<V>names the data, halves the memory, and needs no new read grammar, because reads already follow a domain's walk order. Ryan agreed. - Open. An upper triangle (row
ilists every laterj) walks the pairs in lexicographic order, and a triangle that includes its diagonal is notPair<V>. Neither is in the corpus. - Reverse. Delete
spec/std/pair.cpand its prelude line, the row in chapter 04 and the line in chapter 10, and restore the hand-written readers in the egoi23p4 and cco20p4 ports.