added `avg` function in Num module
drkameleon yaniszaf@gmail.com
Fri, 22 Jan 2021 07:02:05 +0100
1 files changed,
13 insertions(+),
0 deletions(-)
jump to
M
minpkg/lib/min_num.nim
→
minpkg/lib/min_num.nim
@@ -151,4 +151,17 @@ i.push c.int.newVal
else: i.push c.newVal + def.symbol("avg") do (i: In): + var s: MinValue + i.reqQuotationOfNumbers s + var c = 0.float + for n in s.qVal: + if n.isFloat: + c = + n.floatVal + else: + c = c + n.intVal.float + + c = c / len(s.qVal).float + i.push c.newVal + def.finalize("num")