I would assume that this is a FAQ, but it seems to be impossible to get reasonable search results for overloaded terms like "perl product" or "multiply array."
At any rate, I have this procedure for multiplying a list of numbers:
sub product { my $list = shift; my $prod = 1; foreach my $num (@$list) { $prod *= $num; } return $prod; }
However, with the loop and all, it seems like a terribly inefficient method of doing such a thing. Anyone have a smarter way?
In reply to Product of a list of numbers? by ruffer_rinsin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |