iterate<U> static method
Apply Op on previous state of base and return all results
Implementation
static IList<U> iterate<U>(U base, int count, Op<U> op) {
IList<U> iterations() {
final l = List.filled(count, base, growable: false);
U acc = base;
int i = 1;
l[0] = acc;
while (i < count) {
acc = op(acc);
l[i] = acc;
i += 1;
}
return l.lock;
}
return count > 0 ? iterations() : <U>[].lock;
}