Averages/Arithmetic mean: Difference between revisions
Content deleted Content added
Update WDTE example for language overhaul. |
m Lingo added |
||
Line 1,633: | Line 1,633: | ||
return n / (real len a); |
return n / (real len a); |
||
}</lang> |
}</lang> |
||
=={{header|Lingo}}== |
|||
<lang Lingo>-- v can be (2D) point, (3D) vector or list of integers/floats |
|||
on mean (v) |
|||
case ilk(v) of |
|||
#point: cnt = 2 |
|||
#vector: cnt = 3 |
|||
#list: cnt = v.count |
|||
otherwise: return |
|||
end case |
|||
sum = 0 |
|||
repeat with i = 1 to cnt |
|||
sum = sum + v[i] |
|||
end repeat |
|||
return float(sum)/cnt |
|||
end</lang> |
|||
<lang Lingo>put mean(point(1, 2.5)) |
|||
-- 1.7500 |
|||
put mean(vector(1.2, 4.7, 5.6)) |
|||
-- 3.8333 |
|||
put mean([6,12,18,24,30,36,42,48,54,60,66,72,78]) |
|||
-- 42.0000</lang> |
|||
=={{header|LiveCode}}== |
=={{header|LiveCode}}== |