all repos — min @ 7f00658403b1903c8a3ad6f8c686b0dc5bea8b01

A small but practical concatenative programming language.

added `range` function to Num library
drkameleon yaniszaf@gmail.com
Fri, 22 Jan 2021 09:39:14 +0100
commit

7f00658403b1903c8a3ad6f8c686b0dc5bea8b01

parent

50f2e759d8d36232ab6705c2f98a0b0a7f740224

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

jump to
M minpkg/lib/min_num.nimminpkg/lib/min_num.nim

@@ -181,5 +181,27 @@ if second.isFloat:

i.push ((first.intVal.float+second.floatVal)/2).newVal else: i.push ((first.intVal+second.intVal).float/2).newVal + + def.symbol("range") do (i: In): + var s: MinValue + i.reqQuotationOfNumbers s + var a = s.qVal[0] + var b = s.qVal[1] + var step = 1.newVal + var res = newSeq[MinValue](0) + if len(s.qVal)==3: + a = s.qVal[0] + b = s.qVal[1] + step = s.qVal[2] + var j = a + if a.intVal < b.intVal: + while j.intVal <= b.intVal: + res.add j + j = (j.intVal + step.intVal).newVal + else: + while j.intVal >= b.intVal: + res.add j + j = (j.intVal - step.intVal).newVal + i.push res.newVal def.finalize("num")