diff options
author | Julien Dessaux | 2021-10-06 22:06:05 +0200 |
---|---|---|
committer | Julien Dessaux | 2021-10-06 22:06:05 +0200 |
commit | ba8933937e0b24e5a648ec176c4f0b8515fb0e2d (patch) | |
tree | 33ecdbf0e99eeee21a90a66aba21550dee6c6c74 /src/stackStack.nim | |
parent | Implemented steps over a funge space field (diff) | |
download | nimfunge98-ba8933937e0b24e5a648ec176c4f0b8515fb0e2d.tar.gz nimfunge98-ba8933937e0b24e5a648ec176c4f0b8515fb0e2d.tar.bz2 nimfunge98-ba8933937e0b24e5a648ec176c4f0b8515fb0e2d.zip |
Implemented missing functions for the interpreter
Diffstat (limited to '')
-rw-r--r-- | src/stackStack.nim | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/stackStack.nim b/src/stackStack.nim index d55d5d9..b2bf29f 100644 --- a/src/stackStack.nim +++ b/src/stackStack.nim @@ -52,8 +52,7 @@ func End*(ss: var StackStack, v: var tuple[x, y: int]): bool = let toss = ss.head let soss = toss[].Next() let n = toss[].Pop() - v.y = soss[].Pop() - v.x = soss[].Pop() + (v.x, v.y) = soss[].PopVector() if n > 0: soss[].Transfert(toss[], n) else: @@ -61,3 +60,22 @@ func End*(ss: var StackStack, v: var tuple[x, y: int]): bool = dec ss.height ss.head = soss return false + +func Under*(ss: var StackStack): bool = + if ss.height == 1: + return true + let soss = ss.head[].Next() + let n = ss.Pop() + if n > 0: + for i in 0..<n: + ss.Push(soss[].Pop()) + else: + for i in 0 ..< -n: + soss[].Push(ss.Pop()) + return false + +func GetHeights*(ss: StackStack): (int, seq[int]) = + return (ss.height, ss.head[].GetHeights) + +func YCommandPick*(ss: var StackStack, n, h: int) = + ss.head[].YCommandPick(n, h) |