138. Sequences, search/DP and graph/tree API rounds (proposed, 2026-11-21)
- Status. Proposed in
spec/core/07-sequences.md,search-dp.mdandgraphs-trees.md; under review with Ryan. Sequence stubs follow round 2:Slice<S>replacesView<T>;scan(withfrom:) moved tostd.prefixand returnsPrefix; suffix folds area.rev.scan(op);with_prevstays (path walks need the first step apart);List.takebecametake_allsotake(k)is the view. - Sequences. One protocol,
Seq<T>(iter() -> yields T); generators are the only iterator, push-based, and a generator value is a recipe rerun by eachfor.Indexed<D, T>adds O(1)s[i]ands.keys. The key type decides slicing: domain slices keep positions (a[l..=r][i]isa[i]),List/Strslices count from 0, since anIntoffset has no identity and no type would stoprest[i]reading the wrong element. A literal is never a position into a domain slice.drop/takeare O(1) views,q[r] = sis length-checked slice assignment,.collect()ends a chain,pre[v]is the inclusive prefix next topre[c], and lint flags lazy chains consumed twice or with mutating closures. These replace 0-basedView<T>and.at(i).a.map(f)stays indexed. Position queries are folds overa.keys(noargmin/ordertwins).a.scan(op)is cut-indexed;a.rev.scan(op)gives suffix folds on the same cuts.a.allbecomesa.keysandV.allbecomesV.range, sinces.all(p)is the predicate and there is no overloading (§127). - Search/DP.
peak/valleyfor unimodal search;F64ends make an interval withbsearch/peak; tables are typed by state ([V.ranges]for interval DP withr.splits,[B.subsets]for masks);@memo fncaches in a table when all parameters are finite; speed-ups take the plain DP's cost function. - Graphs/trees.
g[u]is the O(1) arcs view; algorithms takenext; storage follows the vertex type; groupings return fresh domains;t.order(parents first) gives recursion-free tree DP. - Reverse. Each doc's "Open" section lists the alternative per call.