Skip to content

Instantly share code, notes, and snippets.

@zakaluka
Created February 17, 2017 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zakaluka/373ae5faffd058077246ec48091fb38c to your computer and use it in GitHub Desktop.
Save zakaluka/373ae5faffd058077246ec48091fb38c to your computer and use it in GitHub Desktop.
let advance dist loc =
match loc.dir with
| North ->
let npt = { x = loc.pt.x; y = loc.pt.y + dist }
{ loc with pt = npt }
| South ->
let npt = { x = loc.pt.x; y = loc.pt.y - dist }
{ loc with pt = npt }
| West ->
let npt = { x = loc.pt.x - dist; y = loc.pt.y }
{ loc with pt = npt }
| East ->
let npt = { x = loc.pt.x + dist; y = loc.pt.y }
{ loc with pt = npt }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment