If you are limited to 4x4 matrices, you can use !! ("Get the Nth element out of a list"):
mat = [
[ 1, 2, 3, 4],
[ 5, 6, 7, 8],
[ 9,10,11,12],
[13,14,15,16]
]
output = [
[e 0 0, e 0 1, e 1 0, e 1 1],
[e 0 2, e 0 3, e 1 2, e 1 3],
[e 2 0, e 2 1, e 3 0, e 3 1],
[e 2 2, e 2 3, e 3 2, e 3 3]
]
where e i j = mat!!i!!j
General solution
filterByIndex :: (Int -> Bool) -> [a] -> [a]
filterByIndex p xs = [x | (x,i) <- zip xs [0..], p i]
filterByIndex2D :: (Int -> Bool) -> (Int -> Bool) -> [[a]] -> [[a]]
filterByIndex2D pr pc rows = [filterByIndex pc row | (row, i) <- zip rows [0..], pr i]
f :: [[a]] -> [[a]]
f matrix = [
filterMatrix ( <m) ( <m),
filterMatrix ( <m) (>=m),
filterMatrix (>=m) ( <m),
filterMatrix (>=m) (>=m)
]
where m = (length matrix) `div` 2
filterMatrix fi fj = concat $ filterByIndex2D fi fj matrix
mat = [
[ 1, 2, 3, 4],
[ 5, 6, 7, 8],
[ 9,10,11,12],
[13,14,15,16]
]
output = f mat -- [[1,2,5,6], [3,4,7,8], [9,10,13,14], [11,12,15,16]]
Run it
We assume that matrix is a square matrix, and find the index m of a middle element. Then we filter the matrix four times based on this index. Note that this probably is less performant than the 4x4 matrix specific solution above.