104. .map on fixed arrays [D]T / [D, E]T preserves index domains (2026-11-21)
- Decision.
.map(f)on a fixed array[D]Treturns[D]U, and on a multi-dimensional fixed array[D, E]Treturns[D, E]U(so nested[D][E]Tpreserves both domains througha.map(row => row.map(f))).List<T>,Str,Range<I>,Set/HashSet,Domain, and O(1) slices/views remain unchanged and returnList<U>. All other element-wise/shape-preserving stdlib array operations (scan,suffix_scan,prev_less/next_less/prev_greater/next_greater,compose,inverse,perm_pow,copy) already return domain-typed arrays; reordering or length-changing ops (reversed,sorted,filter) stayList. - Why. Mapping over a domain-indexed array keeps a 1-to-1 correspondence with each index position, so dropping to
List<U>threw away the domain proof and forced hand-written comprehensions (e.g.,proto/ports/ecnerwala/dream/agc077a.cp:52,Block(seen.map(f), real.map(f))withseen: [Side]Runfailing with E0302). - Evidence.
array_map_preserves_index_domainincrates/cpl-check/src/tests.rs,crates/cpl-cli/tests/programs/array_map.cp(interpreter + C++17 differential parity across 1D enum/domain/1-based-range/empty arrays, 2D[R, C]T, nested[Side][C]T, and unchangedList/Str/slices), and updatedArray.mapcatalog row ([0..3]Int) passingbuiltin_catalog. Closesresearch/frictions/agc077a.md. - Reverse. Remove the
Ty::Arrayarm for"map"incrates/cpl-check/src/check/call.rs, removelower_array_mapincrates/cpl-ir/src/lower/call.rs, and change theArray"map"row incrates/cpl-check/src/builtins.rsback toList<U>.