Re: how to add a list of numbers



Well, you can add a list of numbers with the module List::Util . It has a routine called "sum".

my @list = (8,10,2,5);
use List::Util qw(sum);
my $sum = sum (@list);
# $sum is now 25

It can add any numbers, random or not.

On Jul 14, 2006, at 11:00 PM, I BioKid wrote:

is there any shortest way to add a list of random numbers ?
for example :
11
1
250
39
100
....
,....

thanks
--
ibiokid

--
Aaron Priven, aaron@xxxxxxxxxx, http://www.priven.com/aaron

.



Relevant Pages

  • Re: lsqcurvefit-converge?
    ... > I have a problem considering lsqcurvefit as a routine to fit a number ... Are you truly looking at the sum of the residuals? ... The latter is what lsqcurvefit uses. ...
    (comp.soft-sys.matlab)
  • Creating a UDF from a VBA routine...
    ... How can I convert the below routine to a UDF ... put the target value in cell B1 ... Sum = Sum + Cells ...
    (microsoft.public.excel.programming)
  • Re: Strange behavior with pointers
    ... > developed a routine to sum the four neighbors of a specific row/column ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Problem measuring code execution time !
    ... This routine integrates the intensity in a monochrome image along a line ... I have coded an assember version of this routine also which is 2-3 times ...
    (comp.lang.pascal.delphi.misc)
  • Strange behavior with pointers
    ... developed a routine to sum the four neighbors of a specific row/column ...
    (microsoft.public.dotnet.languages.vc)