rover

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

commit 3375906dee97e26ece274e310e4cd3488778a761
parent 1ba4399221298da50cb4269921242cf7cab06116
Author: Daniel Barlow <dan@telent.net>
Date:   Sun, 22 Jan 2023 17:51:53 +0000

rename command -> execute

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

diff --git a/rover.fnl b/rover.fnl @@ -12,7 +12,7 @@ :actual actual# }))))) -(fn command [rover [cmd & cmds]] +(fn execute [rover [cmd & cmds]] (let [r1 (match rover.direction :n (merge rover {:y (+ rover.y 1)}) @@ -20,14 +20,14 @@ :w (merge rover {:x (- rover.x 1)}) :e (merge rover {:x (+ rover.x 1)}))] (if (next cmds) - (r1:command cmds) + (r1:execute cmds) r1))) (fn rover [x y direction] {: x : y : direction - : command + : execute }) (let [r (rover 7 15 :n)] @@ -38,28 +38,28 @@ (let [r (rover 0 0 :n)] (expect "The rover receives a character array of commands" - (r:command [:f :f :f]) + (r:execute [:f :f :f]) {})) (let [r (rover 0 0 :n)] (expect "Moves north when pointing north and asked to move forward" - (r:command [:f]) {:x 0 :y 1 :direction :n})) + (r:execute [:f]) {:x 0 :y 1 :direction :n})) (let [r (rover 3 2 :s)] (expect "Moves south when pointing south and asked to move forward" - (r:command [:f]) {:x 3 :y 1 :direction :s})) + (r:execute [:f]) {:x 3 :y 1 :direction :s})) (let [r (rover 0 0 :w)] (expect "Moves west when pointing west and asked to move forward" - (r:command [:f]) {:x -1 :y 0 :direction :w})) + (r:execute [:f]) {:x -1 :y 0 :direction :w})) (let [r (rover 0 0 :e)] (expect "Moves east when pointing east and asked to move forward" - (r:command [:f]) {:x 1 :y 0 :direction :e})) + (r:execute [:f]) {:x 1 :y 0 :direction :e})) (let [r (rover 1 1 :s)] (expect "The rover acts on multiple commands" - (r:command [:f :f :f]) + (r:execute [:f :f :f]) {:x 1 :y -2 :direction :s}))