Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,24 @@
|
|||
cat mean.awk
|
||||
#!/usr/local/bin/gawk -f
|
||||
|
||||
# User defined function
|
||||
function mean(v, i,n,sum) {
|
||||
for (i in v) {
|
||||
n++
|
||||
sum += v[i]
|
||||
}
|
||||
if (n>0) {
|
||||
return(sum/n)
|
||||
} else {
|
||||
return("zero-length input !")
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
# fill a vector with random numbers
|
||||
for(i=0; i < 10; i++) {
|
||||
vett[i] = rand()*10
|
||||
}
|
||||
print mean(vett)
|
||||
print mean(nothing)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue