Just curious does this actually run? I'm trying on pugs 6.2.11 and it complains 
quite a bit. First of all shouldn't

for %buckets.values -> $arg_for

be 

for %buckets.values -> $arg_for is rw

since $arg_for is modified?

And then I get an error telling me 'No such method in class Scalar: "&kv"' in 
the line 

for %buckets<w><array>.kv -> $i, $w {

Is it just me?

Regards

Martin

A. Pagaltzis (10:52 2006-05-24):
>     my %buckets = (
>          w => {
>             count => 4,
>             scale => 10.5,
>          },
>          x => {
>             count => 6,
>             scale => 7,
>          },
>          y => {
>             count => 12,
>             scale => 3,
>          },
>          z => {
>             count => 18,
>             scale => 2,
>          },
>     );
> 
>     for %buckets.values -> $arg_for {
>         $arg_for<array> = [ ( 0 .. $arg_for<count> ) »*« $arg_for<scale> ];
>     }
> 
>     my int @results;
>     my int $target = 35;
> 
>     for %buckets<w><array>.kv -> $i, $w {
>         say "To 4: $i";
>         last if $w > $target;
>         for %buckets<x><array>.kv -> $j, $x {
>             say "  To 6: $j";
>             last if ($w, $x).sum > $target;
>             for %buckets<y><array>.kv -> $k, $y {
>                 last if ($w, $x, $y).sum > $target;
>                 for %buckets<z><array>.kv -> $l, $z {
>                     if( $target == ($w, $x, $y, $z).sum ) {
>                         @results.push( [$i, $j, $k, $l] );
>                     }
>                 }
>             }
>         }
>     }
> 
>     for @results.kv -> $idx, $result {
>         say "$idx: $result.join(' | ')";
>     }
> 
> I assume all those temporaries that I cleaned out were there for
> speed, in which case this will run slower, but they were too
> unsightly to keep around.
> 
> Regards,
> -- 
> #Aristotle
> *AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1};
> &Just->another->Perl->hacker;

Reply via email to