diff --git a/rover.fnl b/rover.fnl index 045852c..85f2b66 100644 --- a/rover.fnl +++ b/rover.fnl @@ -1,4 +1,5 @@ (local { : view } (require :fennel)) +(local { : merge } (require :lume)) (macro expect [text actual expected] `(let [actual# ,actual] @@ -14,10 +15,10 @@ (fn command [rover [cmd & cmds]] (let [r1 (match rover.direction - :n {:x rover.x :y (+ rover.y 1) :direction :n : command} - :s {:x rover.x :y (- rover.y 1) :direction :s : command} - :w {:x (- rover.x 1) :y rover.y :direction :w : command} - :e {:x (+ rover.x 1) :y rover.y :direction :e : command})] + :n (merge rover {:y (+ rover.y 1)}) + :s (merge rover {:y (- rover.y 1)}) + :w (merge rover {:x (- rover.x 1)}) + :e (merge rover {:x (+ rover.x 1)}))] (if (next cmds) (r1:command cmds) r1)))