RosettaCodeData/Task/Averages-Arithmetic-mean/Lingo/averages-arithmetic-mean-1.lingo
2018-06-22 20:57:24 +00:00

14 lines
322 B
Text

-- 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