RosettaCodeData/Task/Averages-Arithmetic-mean/Brat/averages-arithmetic-mean.brat
2023-07-01 13:44:08 -04:00

5 lines
108 B
Text

mean = { list |
true? list.empty?, 0, { list.reduce(0, :+) / list.length }
}
p mean 1.to 10 #Prints 5.5