PinkeyNBrain
IS-IT--Management
I don't use the 'map' command much but though I'd give it try:
The following does what I want
This didn't
Essentially I'm left with
$total = $arr_of_nums[$#arr_of_nums]
Since the first version is working and the code I'm working on isn't sensitive to speed, I'll probably leave well enough alone. But still curious to know if the map command can be used this way. Guess I'm just out skin`in cats.
The following does what I want
Code:
$total = 0;
$total += $_ foreach (@arr_of_nums) ;
This didn't
Code:
$total = 0;
$total = map {$tot += $_} @arr_of_nums) ;
Essentially I'm left with
$total = $arr_of_nums[$#arr_of_nums]
Since the first version is working and the code I'm working on isn't sensitive to speed, I'll probably leave well enough alone. But still curious to know if the map command can be used this way. Guess I'm just out skin`in cats.