All,
I also have successfully written my first perl 6 code! It was a pretty straight forward port of Generating powerset with progressive ordering. The only thing Pugs didn't have that I wanted was @array.end which I am in the process of writing a test for. You see autrijus and the Pugs team has this deal where they will trade working code for a proper test.
use v6; sub iter_powerset ( *@factor ) returns Ref { my @subset = (undef) xx @factor.end; my ($pos, $mode) = (-1, 1); my $return = sub { list @factor[ grep { defined $_ } @subset ] }; my %dispatch = ( 1 => sub { ++$pos; @subset[ $pos ] = $pos; ++$mode if $pos == @factor.end; $return(); }, 2 => sub { @subset[ $pos - 1 ] = undef; ++$mode; $return(); }, 3 => sub { @subset[ $pos-- ] = undef; while ( $pos >= 0 ) { last if defined @subset[ $pos ]; --$pos; } @subset[ $pos++ ] = undef; return () if ! $pos; @subset[ $pos ] = $pos; $mode = 1; $return(); }, ); return sub { %dispatch{ $mode }() }; } my $next = iter_powerset( 1..5 ); my @combo; while ( @combo = $next() ) { @combo.say; }
Incidently, the @array.end feature was waiting for me as soon as I checked in the test.

Cheers - L~R


In reply to Pugs Powerset With Progressive Ordering by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.