24 lines
529 B
Text
24 lines
529 B
Text
$ include "seed7_05.s7i";
|
|
include "float.s7i";
|
|
|
|
const array float: numVector is [] (1.0, 2.0, 3.0, 4.0, 5.0);
|
|
|
|
const func float: mean (in array float: numbers) is func
|
|
result
|
|
var float: result is 0.0;
|
|
local
|
|
var float: total is 0.0;
|
|
var float: num is 0.0;
|
|
begin
|
|
if length(numbers) <> 0 then
|
|
for num range numbers do
|
|
total +:= num;
|
|
end for;
|
|
result := total / flt(length(numbers));
|
|
end if;
|
|
end func;
|
|
|
|
const proc: main is func
|
|
begin
|
|
writeln(mean(numVector));
|
|
end func;
|