Is there a clean and transparent way to build a Table which grows in
length either to some initially specified maximum length, or until a
test is met?
One way to do this is obviously to use a While[ ] loop, adding an
element to the table each time around the loop -- but I've been led to
believe that Append'ing an elements to a list is a slower process.
A related question would be: Is it legal to redefine the upper limit of
the iterator in a Do[ ] or Table[ ] operation? For example would
something like
kMax=100;
Do[ {k, f1=f[k]; If[ f[1<0, kMax=k+1]; f1}, {k,1,kMax}];
build a Table of k and f[k] with up to 100 elements or until f[k] went
negative, whichever came first. (Trial and error says no.)