> Assuming you write the subset coroutine above, how about
> 
>   $score +=
>   ( subsets(0..4) ==> map { 2 * (15 == [+] @[EMAIL PROTECTED]) } ==> [+] )

Working on it last night and this morning, I ended up with the
following, very similar rewrite.

sub gen_idx_powerset (Int $size is copy) returns Array {
   my @c = ([]);
   for 0 .. $size-1 -> $i {
       push @c, (map { [EMAIL PROTECTED], $i] }, @c);
   }
   return @c;
}

# Fifteens
$score += 2 * grep {
   15 == [+]( @[EMAIL PROTECTED]>>.<val> )
}, gen_idx_powerset( [EMAIL PROTECTED] );

(Also available at http://www.perlmonks.org/?node_id=460666)

(I had an error in my original posting. @hand is an AoH. My original
should have hypered to .<val> like my second one does.)

Question: Is it possible using hypers and the like to replace the
gen_idx_powerset() sub with an inline expression? I'm not worried
about maintainability - I wanna see what the new ops can do!

Thanks,
Rob

Reply via email to