in reply to Re^2: Perl6 Contest #2: P6 That Doesn't Look Like P5
in thread Perl6 Contest #2: P6 That Doesn't Look Like P5

That is, the ability to loop over an arbitrary number of lists iteratively with a relatively small memory footprint.

Sure, my outer does that, unless I've misunderstood something. It does not return a Code, though, but a lazy list, and it hasn't the same API as NestedLoops, as I was concentrating on the algorithm.

Your solution certainly produces the same output but not 1 at a time and appears to hold everything in memory at once.

Yep, this is as to get even only one item, the helper sub has to be executed recursively several times. I.e., in general:

{ ...; recurse ...; take ...; ...; } # not so good { ...; take ...; recurse ...; ...; } # better (items are yielded ASAP)

Therefore my solution should probably not be included in a library, as the other solutions presented scale much better. I do think that my solution is rather elegant though (no for, few lines of code).

--Ingo