all repos — min @ b2e6078d7421f7512f0fb026b8cd6e999b8cc111

A small but practical concatenative programming language.

added `avg` function in Num module
drkameleon yaniszaf@gmail.com
Fri, 22 Jan 2021 07:02:05 +0100
commit

b2e6078d7421f7512f0fb026b8cd6e999b8cc111

parent

e07e734ae1f6a9246aca9b1ddc87d702409d4063

1 files changed, 13 insertions(+), 0 deletions(-)

jump to
M minpkg/lib/min_num.nimminpkg/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")