static int smartIndexOfPred(L l, IF1 pred) { int n = l(l); for i to n: if (pred.get(l.get(i))) ret i; ret n; }