static L replaceSublist(L l, L x, L y) {
if (x == null) ret l;
int i = 0;
while (true) {
i = indexOfSubList(l, x, i);
if (i < 0) break;
// It's inefficient :D
for (int j = 0; j < l(x); j++) l.remove(i);
l.addAll(i, y);
i += l(y);
}
ret l;
}
static L replaceSublist(L l, int fromIndex, int toIndex, L y) {
// TODO: optimize more
removeSubList(l, fromIndex, toIndex);
l.addAll(fromIndex, y);
ret l;
}
ifclass IntRange
static L replaceSublist(L l, IntRange r, L y) {
ret replaceSublist(l, r.start, r.end, y);
}
endif