I am currently messing around with a haskell issue regarding 2D ST array and recursion.
Given a two-dimensional position and an array of directions, I wrote a line that returns a list of all the resulting points inside the array:
let cellsAround = [resPt | dir <- directions,
let resPt = (fst dir + fst point, snd dir + snd point),
fst resPt >= 0 && fst resPt <= fst maxIdx &&
snd resPt >= 0 && snd resPt <= snd maxIdx]
Now the goal is to enrich the resulting list items with the contents of the array, and I tried this:
cellsAround <- sequence [readArray board resPt | dir <- directions,
let resPt = (fst dir + fst point, snd dir + snd point),
fst resPt >= 0 && fst resPt <= fst maxIdx &&
snd resPt >= 0 && snd resPt <= snd maxIdx]
This also works great. But the goal is to get a combination of both [(Point, Int)], because I have to filter the contents of the array.
Any ideas how to combine this, say
(resPt, readArray board resPt)
?
source
share