Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Product of a list of numbers?

by PodMaster (Abbot)
on Jan 23, 2004 at 01:12 UTC ( [id://323387]=note: print w/replies, xml ) Need Help??


in reply to Product of a list of numbers?

FYI, for future searches, you can safely omit "perl" from "perl product" (what's next, "perl array" ? :)).

However, with the loop and all, it seems like a terribly inefficient method of doing such a thing. Anyone have a smarter way?
Why does it seem inefficient? It's the most straight forward way to accomplish the task. Maybe not as "elegant" (matter of opinion) as
sub product { my $list = shift; my $prod = 1; $prod *= $_ for @$list; return $prod; }
but it's pretty much as efficient as it gets.

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://323387]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-03-28 20:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found