I haven't finished reading the docs yet, so forgive me if this is answered someplace: is there a way to terminate the integers function based on a calculation? For example, suppose I want to generate all the primes < 10,000.

p:i.500

That generates the first five primes, but has no way of knowing whether that's enough or too much. I'd like to use something like

p:i._

which would me give me all the primes (to infinity) but then put a limit on it so that it stops at a certain point -- in this case, when one of the generated primes is about to exceed 10,000.

Is there a way to do that without resorting to a traditional loop?

regards,

geoff
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to