in reply to Product of a list of numbers?
Can't say if its more efficient, but you could use List::Util::reduce.
use List::Util 'reduce'; my @a = ( 1, 2, 3, 4, 5 ); print reduce{ $a * $b } @a; 120
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Product of a list of numbers?
by hippo (Archbishop) on Jun 26, 2022 at 12:41 UTC |