Jump to content

Averages/Pythagorean means: Difference between revisions

Update to work with version 1.4 of Nim. Changed the output to match the actual format.
(Added Wren)
(Update to work with version 1.4 of Nim. Changed the output to match the actual format.)
Line 2,091:
 
=={{header|Nim}}==
<lang nim>import math, sequtils, futuresugar
proc amean(num: seq[float]): float =
Line 2,112:
proc hmeanFunctional(num: seq[float]): float =
float(num.len) / sum(num.mapIt(float, 1.0 / it))
let numbers = toSeq(1..10).map((x: int) => float(x))
echo amean(numbers), " ", gmean(numbers), " ", hmean(numbers)</lang>
{{out}}
<pre>5.5000000000000000e+005 4.5287286881167654e+00528728688116765 3.4141715214740551e+00414171521474055</pre>
 
=={{header|Oberon-2}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.