type position = Plain | Water | Wall | Home type board = position array array
Your task is to write the following functions:
getDims
which takes a board and
returns a pair of integers which are the number of rows and the number
of columns in the board.
isSafe
which takes a board and a
pair of integers (i,j)
. The function should return
true
or false
depending on whether the
location (i,j)
is safe or not. A location is safe if it
is either Plain
or Home
, and unsafe
otherwise.
getNeighbors
which takes a board and
a pair of integers (i,j)
. The function should return a
list of all locations which are to the East, West, North, and South,
unless of course the given input location is on an edge or corner.
getSafeNeighbors
which takes a board
and a pair of integers (i,j)
. The function should return
a list of all neighboring locations which are also safe locations. You
should and in fact must reuse the previous two functions to
solve this one.