First import
git-svn-id: http://photonzero.com/dotfiles/trunk@1 23f722f6-122a-0410-8cef-c75bd312dd78
This commit is contained in:
commit
83d40113d2
60 changed files with 4264 additions and 0 deletions
21
bin/movingaverage
Executable file
21
bin/movingaverage
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
$averageto = $ARGV[0];
|
||||
for ($i = 0; $i < $averageto; $i++) {
|
||||
$temp[$i] = 0;
|
||||
}
|
||||
|
||||
while (<STDIN>) {
|
||||
chomp;
|
||||
$x = 0;
|
||||
for ($i = 0; $i < $averageto; $i++) {
|
||||
$x += $temp[$i];
|
||||
}
|
||||
$x = $x + $_;
|
||||
$x = $x / ($averageto + 1);
|
||||
print "$x\n";
|
||||
for ($i = 0; $i < $averageto - 1; $i++) {
|
||||
$temp[$i] = $temp[($i + 1)];
|
||||
}
|
||||
$temp[($averageto -1)] = $_;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue