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:
parent
bef5a398eb
commit
99dbabcb82
@ -121,7 +121,9 @@
|
|||||||
(fn [stack state]
|
(fn [stack state]
|
||||||
(let [lit-stack (get-vector-literal-type stack)]
|
(let [lit-stack (get-vector-literal-type stack)]
|
||||||
(make-instruction state
|
(make-instruction state
|
||||||
#(get %2 (mod %1 (count %2)))
|
#(if (empty? %2)
|
||||||
|
:ignore-instruction
|
||||||
|
(get %2 (mod %1 (count %2))))
|
||||||
[:integer stack]
|
[:integer stack]
|
||||||
lit-stack))))
|
lit-stack))))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user