all repos — min @ 152a7734a77b0e71360514c2b986281137302cb7

A small but practical concatenative programming language.

Moved num-related operators out of prelude.
h3rald h3rald@h3rald.com
Fri, 24 Mar 2017 21:16:39 +0100
commit

152a7734a77b0e71360514c2b986281137302cb7

parent

406596881be1e879c5db28cb12fb5fa43a6bb66b

3 files changed, 21 insertions(+), 9 deletions(-)

jump to
M lib/min_num.nimlib/min_num.nim

@@ -79,4 +79,24 @@ var a, b: MinValue

i.reqTwoInts b, a i.push(newVal(a.intVal mod b.intVal)) + .symbol("succ") do (i: In): + var n: MinValue + i.reqInt n + i.push newVal(n.intVal + 1) + + .symbol("pred") do (i: In): + var n: MinValue + i.reqInt n + i.push newVal(n.intVal - 1) + + .symbol("even?") do (i: In): + var n: MinValue + i.reqInt n + i.push newVal(n.intVal mod 2 == 0) + + .symbol("odd?") do (i: In): + var n: MinValue + i.reqInt n + i.push newVal(n.intVal mod 2 != 0) + .finalize()
M prelude.minprelude.min

@@ -8,14 +8,6 @@ 'time import

'fs import 'crypto import -; Mathematical Operators -(1 +) :succ -(1 -) :pred -(2 mod 0 ==) :even? -(even? not) :odd? - -('succ 'pred 'even? 'odd?) 'seal foreach - ; Stack Operators (swap cons) :swons ((pop) dip) :popd
M tests/lang.mintests/lang.min

@@ -181,7 +181,7 @@ ('sym1 remove-symbol stored-symbols "sym1" contains false ==) assert

(0 :temp (1 2 3) (temp + @temp) foreach 6 temp ==) assert - ('succ source (1 +) ==) assert + ((1 +) :mysucc 'mysucc source (1 +) ==) assert (6 (