in reply to Perl6 Contest #2: P6 That Doesn't Look Like P5
Now to add the other params . . .#!/usr/bin/pugs use v6; sub NL2 (++@loop) { coro { given (@loop.elems) { when 0 { yield [] } when 1 { @loop[0].map:{ yield [$^first] }; yield undef } default { for @loop[0] -> $first { my &rest = NL2(loop => @loop[1..Inf]); my @rest; while @rest = rest() { yield [$first, @rest]; } } yield undef; } } } } my &iter = NL2(loop => ([0..2], [3..5], [6..8])); my ($cnt, $item); say "ITER {++$cnt}: {$item.perl}" while $item = iter;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Perl6 Contest #2: P6 That Doesn't Look Like P5
by revdiablo (Prior) on Jun 02, 2005 at 22:27 UTC | |
by kaif (Friar) on Jun 03, 2005 at 16:52 UTC | |
by mugwumpjism (Hermit) on Jun 02, 2005 at 22:45 UTC | |
by geoffb (Novice) on Jun 02, 2005 at 22:33 UTC | |
Re^2: Perl6 Contest #2: P6 That Doesn't Look Like P5
by geoffb (Novice) on Jun 03, 2005 at 01:45 UTC | |
by geoffb (Novice) on Jun 03, 2005 at 03:15 UTC | |
Re^2: Perl6 Contest #2: P6 That Doesn't Look Like P5
by Limbic~Region (Chancellor) on Jun 02, 2005 at 22:12 UTC |