rover

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit db552b8c1197885c90f516908c07dd1e3a5ab9f2
parent 94325e53a04bb31d1d8b922d7d66ced4e1109849
Author: Daniel Barlow <dan@telent.net>
Date:   Sun, 22 Jan 2023 18:11:43 +0000

extract common call to merge

Diffstat:
Mrover.fnl | 20++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/rover.fnl b/rover.fnl @@ -31,17 +31,17 @@ } (. direction))) - (fn command [rover string] - (match string - :f (match rover.direction - :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)})) - :r (merge rover {:direction (turn-right rover.direction)}) - :l (merge rover {:direction (turn-left rover.direction)}) - _ (assert false (. "unrecognised command " string)))) + (merge rover + (match string + :f (match rover.direction + :n {:y (+ rover.y 1)} + :s {:y (- rover.y 1)} + :w {:x (- rover.x 1)} + :e {:x (+ rover.x 1)}) + :r {:direction (turn-right rover.direction)} + :l {:direction (turn-left rover.direction)} + _ (assert false (. "unrecognised command " string))))) (fn execute [rover [cmd & cmds]] (let [r1 (command rover cmd)]