Assign coordinates to the elements of a two-dimensional list. This is useful for composing Arrays.
Download (right click, save as, rename as appropriate)
1 2 3
indexGrid :: [[a]] -> [((Int, Int), a)] indexGrid grid = [((y, x), e) | (y, row) <- zip [0..] grid, (x, e) <- zip [0..] row]