static L replaceElementOnce(L l, A a, A b) { for i over l: if (eq(l.get(i), a)) { l.set(i, b); ret l; } ret l; }