// TODO: test; also we could keep the pairs/triples static O smallestList_set(O l, int i, O o) { if (i < 0 || i >= smallestList_l(l)) fail("Index out of bounds"); if (l << Pair) { if (i == 0) l/Pair.a = o; else l/Pair.b = o; ret l; } if (l << T3) { if (i == 0) l/T3.a = o; else if (i == 1) l/T3.b = o; else l/T3.c = o; ret l; } if (l instanceof O[]) { ((O[]) l)[i] = o; ret l; } ret o; }