Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
|
|
@ -1,3 +1,6 @@
|
|||
---
|
||||
category:
|
||||
- Arithmetic
|
||||
- Simple
|
||||
from: http://rosettacode.org/wiki/Averages/Arithmetic_mean
|
||||
note: Probability and statistics
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
[9 5 7 8 6] | math avg
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
##
|
||||
|0, 0, 3, 1, 4, 1, 5, 9, 0, 0|.average.println;
|
||||
Loading…
Add table
Add a link
Reference in a new issue