14 lines
322 B
Text
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
|