static void replaceLastElement(L l, A a) { if (nempty(l)) l.set(l(l)-1, a); }