First off, thanks to Aristotle for clearing some of my thinking.
----- Original Message ----
From: A. Pagaltzis <[EMAIL PROTECTED]>
> my %buckets = (
> w => {
> count => 4,
> scale => 10.5,
> },
<snip>
> );
>
> for %buckets.values -> $arg_for {
> $arg_for<array> = [ ( 0 .. $arg_for<count> ) »*« $arg_for<scale> ];
> }
In my version of Pugs (6.2.11 (r10390)), that fails for two reasons, both of
which I suspect are bugs. First, unless the hash elements have an "array =>
[]" pair, I seem to get the following error:
*** Can't modify constant item: VUndef
at bucket.p6 line 21, column 5-73
Line 21 in my code is the assignment to $arg_for<array>.
However, even putting that back in results in the exact same error, so I had to
change the line to:
$arg_for<array>.push((0 .. $arg_for<count>) >>*<< $arg_for<scale> );
Now you might be thinking that I simply needed change the $arg_for<array>
assignment to a push and not included the "array => []" pair, but as it turns
out, I need the pair *and* the push lest I get the VUndef error.
for %buckets<w><array>.kv -> $i, $w {
Is .kv supposed to work there? You're accessing an array, not a hash.
> 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.
Yeah, that's why they were there. However, the ($x, $y, $z).sum > $target is a
much more useful performance hack, so you could get rid of the temporaries.
Cheers,
Ovid