T0013 — Functions: subsetting and combining
Part of the roadmap. Phase 1 · wave 5 · size S.
- Depends on: T0008, T0009, T0044
- Area:
area:functions - Issue: #25
- Child: T0044 / #141 (first and single)
Goal
N1 §5.3–5.4: last, tail, skip, take, intersect, exclude, union, combine. The indexer was done in T0008.
Parent completion contract
This stable parent retains the original ten-function scope: first and single are delivered by child T0044; the eight functions listed above remain here. The original acceptance below applies to the complete parent, including regression coverage for the child. Keep #25 open after the child merges; a child implementation PR uses Task: T0044 and closes only #141. Close the parent only after all remaining functions and original criteria are fulfilled.
T0044 depends on the already delivered evaluator and equality kernels, not this parent. This parent depends on the child for completion. Existing callers that need only first/single can depend on T0044; full completion dependencies in T0041 and T0038 continue to target T0013. Neither task has a selected release, milestone or due date.
Design
last,tail,skip,take,intersectandexcludeare infunctions/subsetting.ts, next tofirstandsingle;unionandcombineare infunctions/combining.ts. All are value functions: the evaluator passesotherandnumevaluated, with the focus of the call (spec notes).- Every function returns the input items themselves, so object identity, model type and model-less date provenance survive.
union()is the|operator (BINARY_OPERATIONS['|']), as the spec calls them synonymous;intersect()andexclude()use the sameitemEquals()kernel, andcombine()usesconcat(). Noarea:corefile changes. - The decisions the spec leaves open are in the spec notes: an empty
skip()ortake()count gives empty, an undetermined equality is not equal, and the order of every result is fixed. combine(other)takes one argument; the STUpreserveOrderis T0027, which adds it as an optional parameter.
Acceptance criteria
- The spec examples are tests.
single()on more than one item raiseseval/singleton-expected. - Conformance groups:
testSingle,testFirstLast,testTail,testSkip,testTake,testIntersect,testExclude,testUnion,testCombine()(except the STUpreserveOrdercases), andtestDollaronce T0012, T0042, T0015 and T0017 are merged (itsinvalid="semantic"case needs T0024 for a compile-time error; until then it counts as "detected late"). In R4 and R5, every test of these groups passes except those that call a function of another task, which pass once that task is merged:empty()(T0041):testSkip7,testSkip8,testTake8,testTake9,testIntersect2andtestIntersect3; the unit tests check the same results withoutempty().isDistinct()(T0041):testCombine1.select()(T0042):testUnion9,testUnion10andtestUnion11; the unit tests check the same arguments insidewhere().testDollarOrderNotAllowedexpects a semantic error forPatient.children().skip(1)in strict mode (T0024); the evaluator gives a result instead, so it does not even count as "detected late".