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/stack.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/stack.nim | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/stack.nim b/src/stack.nim index f08baf0..4565b5c 100644 --- a/src/stack.nim +++ b/src/stack.nim @@ -80,3 +80,19 @@ func Discard*(s: var Stack, n: int) = func Next*(s: Stack): ref Stack = return s.next + +func GetHeights*(s: Stack): seq[int] = + if s.next != nil: + result = s.next[].GetHeights() + result.add(s.height) + else: + return @[s.height] + +func YCommandPick*(s: var Stack, n, h: int) = + if n > s.height: + s.height = 1 + s.data[0] = 0 + else: + let v = s.data[s.height-n] + s.height = h + s.Push(v) |