Jump to content

Averages/Arithmetic mean: Difference between revisions

m
m (→‎{{header|Wren}}: Changed to Wren S/H)
m (→‎{{header|Sidef}}: updated code)
Line 3,559:
=={{header|Sidef}}==
<syntaxhighlight lang="ruby">func avg(Array list) {
list.len > 0 || return 0;
list.sum / list.len;
}
 
say avg([Math.infInf, Math.infInf]);
say avg([3,1,4,1,5,9]);
say avg([1e+20, 3, 1, 4, 1, 5, 9, -1e+20]);
say avg([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0.11]);
say avg([10, 20, 30, 40, 50, -100, 4.7, -1100]);</syntaxhighlight>
{{out}}
<pre>inf
Inf
3.833333333333333333333333333333333333333
3.83333333333333333333333333333333333333333333333
2.875
3.674
-130.6625</pre>
</pre>
 
=={{header|Slate}}==
2,747

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.