I represented a 3D coordinate with a tuple of type (Int, Int, Int)
To get the direct neighbours of a coordinate I did something like this :
neighbours (x,y,z) =
[(x',y',z') | x' <- [(x-1)..(x+1)], y' <- [(y-1)..(y+1)], z' <- [(z-1)..(z+1)], (x,y,z) /= (x',y',z')]
Now, I need to use 4D coordinates too, I could do something very similar to get the neighbours with a tuple of 4 elements and it would work. But, I would need to duplicate all the functions I did for the 3D coordinates, this time for 4D coordinates.
To avoid this, I thought of basically replacing tuples with a list of Int, now for a 3D coordinate it would be for example [9, 3, 0] and a 4D coordinate [5, 1, 0, 1] and so on.
How can I get the neighbours with an array of Int ? I tried using list comprehension but I failed finding a solution.
PS: I am new to Haskell and functional programming