Averages/Arithmetic mean: Difference between revisions

m
Line 1,629:
{{VI solution|LabVIEW_Averages_Arithmetic_mean.png}}
 
=={{header|Langurlangur}}==
The built-in mean() function works with an array, hash, or range of numbers.
 
We could use fold() to write a function that takes an array and calculates the mean.
 
<lang Langurlangur>val .mean = f(.arr) fold(f .x + .y, .arr) / len(.arr)
 
writeln .mean([7, 3, 12])
990

edits