static IterableIterator> allCombinations(final LL base) { ret iteratorFromFunction(new F0>() { final int n = l(base); L l = rep((Int) 0, n); public L get() { if (l == null) null; L out = makeList(); int i = 0; while (i < n) { int n = l.get(i); if (n+1 < l(base.get(i))) { l.set(i, n+1); break; } l.set(i++, 0); } if (i >= n) l = null; ret out; } L makeList() { L list = emptyList(n); for i to n: list.add(base.get(i).get(l.get(i))); ret list; } }); }