srecord noeq LexicographicIterator(S alphabet) extends ItIt { new IntBuffer l; *(S *alphabet, int minLength) { repeat minLength { l.add(0); } } public bool hasNext() { ret true; // haha! } public S next() { S s = makeString(); int i = 0; while (i < l(l)) { int n = l.get(i); if (n+1 < l(alphabet)) { l.set(i, n+1); break; } l.set(i++, 0); } if (i >= l(l)) l.add(0); ret s; } S makeString() { int n = l(l); char[] chars = new[n]; for i to n: chars[i] = alphabet.charAt(l.get(i)); ret str(chars); } }