I am enrolled at the Art Institute of Pittsburgh - Online working towards a Bachelor of Science in photography.
My other blog [blogspot.com]
my $count;
my @apples = (32, 38, 37, 29, 41); # apples in each bushel
$count += $_ for @apples; # total number of apples
$count.say;
I'd like to do it like this (if it's valid to declare $count in this way):
my @apples = (32, 38, 37, 29, 41); # apples in each bushel
my $count +=<<@apples; # total number of apples
$count.say;
Another example where hyper operators would be nice:
my @credits = (5, 20, 125.50, 37.25);
my @debits = (3.66, 11.77, 23.99, 40.12, 9.95);
my @balances = @credits;
@balances[$_] -= @debits[$_] for (0.. @debits.elems - 1);
my $total;
$total += $_ for @balances;
$total.say;
Could be written as:
my @credits = (5, 20, 125.50, 37.25);
my @debits = (3.66, 11.77, 23.99, 40.12, 9.95);
my @balances = @credits >>-<< @debits;
my $total +=<<@balances;
$total.say;
sum? (Score:2)
That's not how you should use them, though, I think. With op= and then a list on the RHS, you're better off with good old for, or just sum:
Re:sum? (Score:1)