Skip to content

Instantly share code, notes, and snippets.

@nicolasbrugneaux
Created July 21, 2015 12:28
Show Gist options
  • Save nicolasbrugneaux/4e085a125ec16e6c4210 to your computer and use it in GitHub Desktop.
Save nicolasbrugneaux/4e085a125ec16e6c4210 to your computer and use it in GitHub Desktop.
more haslly please?
navigate :: Direction -> Coordinate -> Maze -> Maybe Coordinate
navigate direction (x, y) m = case direction of
N -> if isJust (getCellAt newCell m) then Just newCell else Nothing where
newCell = (x - 1, y)
E -> if isJust (getCellAt newCell m) then Just newCell else Nothing where
newCell = (x, y + 1)
S -> if isJust (getCellAt newCell m) then Just newCell else Nothing where
newCell = (x + 1, y)
W -> if isJust (getCellAt newCell m) then Just newCell else Nothing where
newCell = (x, y - 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment