// f: func -> A
static IterableIterator iteratorFromSingleFunction(fO f) {
ret new IterableIterator() {
A a;
bool done;
public bool hasNext() {
getNext();
ret !done;
}
public A next() {
getNext();
if (done) fail();
A _a = a;
a = null;
ret _a;
}
void getNext() {
if (done || a != null) ret;
a = (A) callF(f);
done = a == null;
}
};
}