moves forward southwards
This commit is contained in:
parent
74fb26f293
commit
89945064d5
10
rover.fnl
10
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")
|
||||
|
Loading…
Reference in New Issue
Block a user