note
tmoertel
Can you define what you mean by "flattening" and "arbitrary depth"? My understanding of these things does not lead me to see unresolved problems in the original post. (Also, I do not believe that the <tt>NestedLoops</tt> code you provided is equivalent to <em>seq_prod</em>.)
<p>In the OP's example <em>while</em> loop, the iterator returns scalar values. Thus I don't see how the <em>seq_prod</em> of such iterators could "flatten" the results: there are no intermediate array results to flatten.
<p>On the arbitrary depth issue, if you mean that <em>iter_prod</em> works only for a fixed number of iterators, that is not the case. You can pass it any number of iterators, and (as long as they are independent) it will yield an iterator over their Cartesian product.
If you mean something else, say that the Cartesian product is not what is desired, we can derive a suitable combinator to replace <em>seq_prod2</em> and use it (with <em>reduce</em>) to build the desired output iterator. For example, we could define a combinator that takes the product of two iterators when the second is generated dynamically from the output of the first.
<p>Cheers,<br>Tom
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-109406">
<p><small><strong>Tom Moertel</strong> : <a href="http://community.moertel.com/">Blog</a> / <a href="http://community.moertel.com/ss/space/Talks">Talks</a> / <a href="http://search.cpan.org/~tmoertel/">CPAN</a> / <a href="http://community.moertel.com/LectroTest">LectroTest</a> / <a href="http://community.moertel.com/ss/space/PXSL">PXSL</a> / <a href="http://community.moertel.com/ss/space/A+Coder%27s+Guide+To+Coffee">Coffee</a> / <a href="http://community.moertel.com/ss/space/IMDB+Movie-Rating+Decoder+Ring">Movie Rating Decoder</a></small></p>
</div></div>
478366
478413