Fix error in vector/_nth

Similar to `vector/_first` and `vector/_last`, `vector/_nth` would not check for the case of an empty vector and would divide by 0. This changes the instruction so that it simply throws `:ignore-instruction` in that case.
This commit is contained in:
Erik Rauer 2020-12-29 16:21:15 -06:00
parent bef5a398eb
commit 99dbabcb82

View File

@ -121,7 +121,9 @@
(fn [stack state]
(let [lit-stack (get-vector-literal-type stack)]
(make-instruction state
#(get %2 (mod %1 (count %2)))
#(if (empty? %2)
:ignore-instruction
(get %2 (mod %1 (count %2))))
[:integer stack]
lit-stack))))