51. Seq and Indexed trait unification (2026-11-21)
- Built-in
SeqandIndexedtraits are backed by one centralTy::seq_elem()/is_seq()/is_indexed()predicate incpl-checkandcpl-ir.Str,List<T>, 1D[D]T,Range<I>, and O(1) slice/reverse views all satisfySeqandIndexedwithout conversion, and generic functions written<S: Seq, T>or<S: Indexed>check bounds at instantiation and deduce element typeTfromS. Reason: eliminates per-container overloads (runs,prefix_function,z_function,is_palindrome,is_sorted,prod,pairs,excl_fold,sum/min/max) and gives O(1) views a single plug-in point (Ty::StrView,Ty::ListView). Reverse: revertseq_elem/is_seq/is_indexedand restore concrete parameter types instdlib/seq.cpandstdlib/strings.cp. - Zero-based
s.at(i)ands.get(i)are the uniformIndexedaccessors, whilea[i]preserves domain safety on[D]T.Strgains.first,.last,.last(k),.get(i),.at(i);Range<I>gainsr[i],.get(i),.at(i),.last(k)andsum/min/max/runs; 1D[D]Tgains.get(i)and.at(i). Generic<S: Indexed>algorithms (such asprefix_functionandz_function) index vias.at(i)so nominal-domain arrays[V]Twork without weakeningWRONG_DOMAINchecks ona[i]. Reverse: removeat/getarms incpl-ir/src/lower/call.rs.