From 65e298c82cd8fca858dde423450d0008029bfe8b Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Mon, 23 Jan 2023 22:39:06 +0000 Subject: [PATCH] extract lateral? function --- rover.fnl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rover.fnl b/rover.fnl index 6fbdb8f..c0405d7 100644 --- a/rover.fnl +++ b/rover.fnl @@ -10,9 +10,12 @@ (any obstacles (fn [[ox oy]] (and (= ox x) (= oy y))))) +(fn lateral? [direction] + (. {:w true :e true} direction)) + (fn try-to-drive [{: x : y : direction : stopped} distance] (let [distance - (if (. {:w true :e true} direction) + (if (lateral? direction) (/ distance (math.cos (/ (* math.pi y) 180))) distance)] (match direction