Thread Durchschnitt der Array Elemente (5 answers)
Opened by Ronnie at 2005-08-10 11:23

Ronnie
 2005-08-10 11:23
#57100 #57100
User since
2003-08-14
2022 Artikel
BenutzerIn
[default_avatar]
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl

use strict;
use warnings;

use List::Util qw/sum/;

my @list = (1, 2, 4, 2);
my $avg = avg(@list);
print $avg, "\n";
exit;

sub avg {
my $sum = sum @_;
my $len = scalar @_;
return $sum/$len;
}

View full thread Durchschnitt der Array Elemente