Data update

This commit is contained in:
Ingy döt Net 2024-10-16 18:07:41 -07:00
parent 81fd053722
commit 52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions

View file

@ -1,3 +1,6 @@
---
category:
- Arithmetic
- Simple
from: http://rosettacode.org/wiki/Averages/Arithmetic_mean
note: Probability and statistics

View file

@ -1,11 +1,6 @@
fun mean = real by some real values
real sum
int count
for each real value in values
sum += value
++count
end
return when(count == 0, 0.0, sum / count)
end
fun mean ← <some real values|when(values.length æ 0,
0.0,
values.fold(0.0, <real x, real y|x + y) / values.length)
^|the mean is calculated by folding the list|^
writeLine(mean())
writeLine(mean(3,1,4,1,5,9))
writeLine(mean(3, 1, 4, 1, 5, 9))

View file

@ -0,0 +1 @@
[9 5 7 8 6] | math avg

View file

@ -0,0 +1,2 @@
##
|0, 0, 3, 1, 4, 1, 5, 9, 0, 0|.average.println;