142. Six sequence capabilities (2026-11-21)
- Decision.
Seq(walk),Keyed(walk(key, x)),Sized(O(1).len),Bidir(walk backwards),Indexed(O(1)s[k], contiguouskeys; implies the three before it) andIndexedMut(s[k]is a place), plusContainsforx in son sub-linear lookups only. Each operation asks for the weakest one that keeps its cost:findandargmaxneedKeyed,sorted()needsSeq,sort()needsIndexedMut. Adapters implement each capability they keep O(1), soFilterhasSeq,KeyedandBidirimpls. Generators areSeqonly;s.keyed(keys)attaches keys by walk order (default0.., a counter) ands.keyed(by: f)takes them from values, soenumeratestays out (60): the counter walk iss.keyed().items.Bidiravoids a clash withstd.algebra'sReversible(fold values read backwards). - Why. Ryan: "argmax just wants smth that has the concept of having
keys ...
.findclearly doesn't need random access". With identity keys,a.filter(p).argmax()answers with a key ofa. He preferred three impls per adapter in library code over keying every sequence. - Reverse. Fold
KeyedintoSeq(generators keyed by yield number), or stop adapters forwardingBidir.