all repos — min @ 2b199bfdf8342cf9736a2bc2cc514840cb75ed71

A small but practical concatenative programming language.

Added popop, rollup, rolldown operator.
h3rald h3rald@h3rald.com
Sun, 26 Mar 2017 14:18:34 +0200
commit

2b199bfdf8342cf9736a2bc2cc514840cb75ed71

parent

1f4fb40ab3a36f9d5bc3cf683cabacee447aadd2

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

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

@@ -32,6 +32,12 @@ if i.stack.len < 1:

raiseEmptyStack() discard i.pop + .symbol("popop") do (i: In): + if i.stack.len < 2: + raiseEmptyStack() + discard i.pop + discard i.pop + # (pop) dip .symbol("popd") do (i: In): i.push newVal(@["pop".newSym], i.scope)

@@ -77,6 +83,26 @@ let a = i.pop

let b = i.pop i.push a i.push b + + .symbol("rollup") do (i: In): + if i.stack.len < 3: + raiseEmptyStack() + let first = i.pop + let second = i.pop + let third = i.pop + i.push first + i.push second + i.push third + + .symbol("rolldown") do (i: In): + if i.stack.len < 3: + raiseEmptyStack() + let first = i.pop + let second = i.pop + let third = i.pop + i.push second + i.push first + i.push third # (swap) dip .symbol("swapd") do (i: In):