Re: Summary for mean/average calculation in perl

2006-09-10 Thread Bryan Harris
> :: ... and cute tricks should only be used in cute programs. > : > : I'll take that as a compliment -- thanks, John! > > He said cute programs, not cute programmers. ... that he thought it was a cute trick, not me. Ha ha. - B -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additi

RE: Summary for mean/average calculation in perl

2006-09-10 Thread Charles K. Clarkson
Bryan Harris wrote: :: ... and cute tricks should only be used in cute programs. : : I'll take that as a compliment -- thanks, John! He said cute programs, not cute programmers. HTH, Charles K. Clarkson -- Mobile Homes Specialist Free Market Advocate Web Programmer 254 968-8328 Don't t

Re: Summary for mean/average calculation in perl

2006-09-10 Thread Bryan Harris
> chen li wrote: >> >> --- "John W. Krahn" <[EMAIL PROTECTED]> wrote: >> >>> chen li wrote: >>> 6)$mean = eval(join("+", @data)) / @data; Depending on how you understand Perl and what >>> progress you are I prefer 6). >>> Depending on how you understand Perl, 6 is the wors

Re: Summary for mean/average calculation in perl

2006-09-10 Thread John W. Krahn
chen li wrote: >>>4)my $mean = do { my $s; $s += $_ for @data; $s / >>>@data }; > > I never see the usage of "for" like this before. Is it > equal to the following? Yes, except that above $s is only visible inside the code block while below $s is visible to the file. > And where can I find some

Re: Summary for mean/average calculation in perl

2006-09-10 Thread chen li
> > 4)my $mean = do { my $s; $s += $_ for @data; $s / > > @data }; Hi, I never see the usage of "for" like this before. Is it equal to the following? And where can I find some more like this? my $s; for(@data){$s += $_ ;} my $mean=$s/@data; Thanks, Li

Re: Summary for mean/average calculation in perl

2006-09-10 Thread Chad Perrin
On Sun, Sep 10, 2006 at 07:12:08AM -0700, chen li wrote: > > 2)List::Util is "built-in" as of 5.8, and back > compatible to 5.5 > > use List::Util qw(sum); > > my $average = sum(@input) / @input; > > > 6)$mean = eval(join("+", @data)) / @data; > > Depending on how you understand Perl a

Re: Summary for mean/average calculation in perl

2006-09-10 Thread John W. Krahn
Rob Dixon wrote: > John W. Krahn wrote: >> chen li wrote: >> >>> 5) my $mean+=$_/@data [EMAIL PROTECTED]; >> >> That was not posted and it won't work correctly (see the NOTE at the >> end of >> the "Statement Modifiers" section of perlsyn.) > > Ruud posted it in the 'perl built in function for mea

Re: Summary for mean/average calculation in perl

2006-09-10 Thread Rob Dixon
Rob Dixon wrote: John W. Krahn wrote: chen li wrote: 5) my $mean+=$_/@data [EMAIL PROTECTED]; That was not posted and it won't work correctly (see the NOTE at the end of the "Statement Modifiers" section of perlsyn.) Ruud posted it in the 'perl built in function for mean' thread at 7:4

Re: Summary for mean/average calculation in perl

2006-09-10 Thread Rob Dixon
John W. Krahn wrote: chen li wrote: 5) my $mean+=$_/@data [EMAIL PROTECTED]; That was not posted and it won't work correctly (see the NOTE at the end of the "Statement Modifiers" section of perlsyn.) Ruud posted it in the 'perl built in function for mean' thread at 7:46 GMT this morning (10

Re: Summary for mean/average calculation in perl

2006-09-10 Thread John W. Krahn
chen li wrote: > > --- "John W. Krahn" <[EMAIL PROTECTED]> wrote: > >>chen li wrote: >> >>>6)$mean = eval(join("+", @data)) / @data; >>> >>>Depending on how you understand Perl and what >>progress >>>you are I prefer 6). >>Depending on how you understand Perl, 6 is the worst >>solution. > > Coul

Re: Summary for mean/average calculation in perl

2006-09-10 Thread chen li
--- "John W. Krahn" <[EMAIL PROTECTED]> wrote: > chen li wrote: > > Dear all, > > Hello, > > > Thank for replying my post. Here is the summary of > all > > the posssible code lines: > > > > Q:If Perl has the short-cut/built-in function for > > calculating Mean/Average? > > > > my @data=(1,

Re: Summary for mean/average calculation in perl

2006-09-10 Thread John W. Krahn
chen li wrote: > Dear all, Hello, > Thank for replying my post. Here is the summary of all > the posssible code lines: > > Q:If Perl has the short-cut/built-in function for > calculating Mean/Average? > > my @data=(1,1,1); > > mean/average=(1+1+1)/3=1; > > A: > > No Perl built-in funct

Summary for mean/average calculation in perl

2006-09-10 Thread chen li
Dear all, Thank for replying my post. Here is the summary of all the posssible code lines: Q:If Perl has the short-cut/built-in function for calculating Mean/Average? my @data=(1,1,1); mean/average=(1+1+1)/3=1; A: No Perl built-in function for mean/average but there are several ways to