Finding the shortest path between two points on a grid, using Haskell.
- by esperantist
This is a problem that I can easily enough solve in a non-functional manner.
But solving it in Haskell is giving me big problems. Me being inexperienced when it comes to functional programming is surely a reason.
The problem:
I have a 2D field divided into rectangles of equal size. A simple grid. Some rectangles are empty space (and can be passed through) while others are impassable. Given a starting rectangle A and a destination rectangle B, how would I calculate the shortest path between the two? Movement is possible only vertically and horizontally, in steps a single rectangle large.
How would I go about accomplishing this in Haskell? Code snippets certainly welcome, but also certainly not neccessary. And links to further resources also very welcome!
Thanks!