From 89945064d54fdb4af36b3b351b56bffbd3540ee3 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sun, 22 Jan 2023 17:15:23 +0000 Subject: [PATCH] moves forward southwards --- rover.fnl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rover.fnl b/rover.fnl index bebdc6f..0d6da5b 100644 --- a/rover.fnl +++ b/rover.fnl @@ -12,7 +12,9 @@ }))))) (fn command [rover commands] - {:x 0 :y 1 :direction :n}) + (match rover.direction + :n {:x 0 :y (+ rover.y 1) :direction :n} + :s {:x 0 :y (- rover.y 1) :direction :s})) (fn rover [x y direction] {: x @@ -38,5 +40,11 @@ (r:command [:f]) {:x 0 :y 1 :direction :n})) +(let [r (rover 0 0 :s)] + (expect + "Moves south when pointing south and asked to move forward" + (r:command [:f]) + {:x 0 :y -1 :direction :s})) + (print "OK")