static L replaceNthItem(L l, int idx, A a) { l = cloneList(l); if (idx < l(l)) l.set(idx, a); ret l; }