I have the following grid:
[["a1","b1", "c1","d1"],
["a2","b2", "c2","d2"],
["a3","b3", "c3","d3"],
["a4","b4", "c4","d4"]]
and would like to extract a range of values in their ‘squares’ so I end up with a list of square values. The x-values are horizontal and y-values are vertical.
I have the following function started:
type Coordinate = (Int,Int)
return :: [[String]] -> Coordinate -> [String]
return grid (x,y) = .....
where (0,0) is the top left corner of the grid. Using the above function I would like to be able to extract a square so I get like this (if my coordinates are (2,0), (3,0), (2,1), (3,1)):
["c1","d1","c2","d2"]
I have tried some methods including the map function but need some tips on how to proceed.
I suggest the following:
applied:
If you indeed need a plain list, apply just type
concat $ localSquare matrix (5,5)