I have a two-dimensional array like this:
A,B,C,D
E,F,G,H
I,J,K,L
M,N,O,P
I need the index of an element of which I know its x and y coordinates as if the array was one-dimensional like this: A,B,C,D,E,F,G...
EDIT: The question wasn't clear. The solution I was looking for would be f(a: array, x: int, y: int) = y * a[0].length + x
Looks like index = row * width + column
to me.