in reply to Re^4: Perl6 Contest: Test your Skills
in thread Perl6 Contest: Test your Skills
sub gen_idx_powerset (Int $size is copy) returns Array { my @c = ([]); for 0 .. $size-1 -> $i { push @c, (map { [@$_, $i] }, @c); } return @c; }
Converted to gather/take
sub gen_idx_powerset (Int $size is copy) returns Ref { my @c = ([]); return gather { take @c[0]; for 0 .. $size-1 -> $i { take for map { [@$_, $i] }, gathered; } }; }
|
---|