Fix string/set-char
This changes `string/set-char` to throw `:ignore-instruction` when the string is empty. Otherwise the instruction throws a Divide by Zero error.
This commit is contained in:
parent
27bd7b6eb6
commit
e3d7963355
@ -268,10 +268,12 @@
|
|||||||
^{:stacks #{:char :integer :string}}
|
^{:stacks #{:char :integer :string}}
|
||||||
(fn [state]
|
(fn [state]
|
||||||
(make-instruction state
|
(make-instruction state
|
||||||
#(let [index (mod %2 (count %3))
|
#(if (empty? %3)
|
||||||
|
:ignore-instruction
|
||||||
|
(let [index (mod %2 (count %3))
|
||||||
beginning (take index %3)
|
beginning (take index %3)
|
||||||
end (drop (inc index) %3)]
|
end (drop (inc index) %3)]
|
||||||
(apply str (concat beginning (list %1) end)))
|
(apply str (concat beginning (list %1) end))))
|
||||||
[:char :integer :string]
|
[:char :integer :string]
|
||||||
:string)))
|
:string)))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user