From: Harry Ohlsen Date: 2003-07-09T12:41:33+09:00 Subject: Possible use for a continuation? [Generating all factors of a given number] Imagine I have an array of arrays, representing the prime factorisation of a number. For example, the array for 12260 would be [[2,3], [3,2], [5,2], [7,1]] What I want to do is to use this to generate all the different factors of the number. This means generating all values of x = 2^a * 3^b * 5^c * 7^d where a ranges from 0 to 3, b from 0 to 2, c from 0 to 2 and d from 0 to 1. However, for space and efficiency reasons, I'd prefer not to have a method that simply returns an array containing all the factors, since in many cases, I'll decide after having processed one of them that I don't need any more. I have a feeling that some kind of recursive method that returns a continuation might be the way to go, but I'm open to any suggestions, whatsoever. The other possibility I can think of is to write an iterator that is recursive (or calls another method that is) and does a yield as the deepest nesting of the recursion. If I did that, would a "break" from inside the block passed to that iterator work the way I would normally expect it to? I feel like it probably would, but am wondering because of the recursion. Thanks in advance, Harry O.