I need to construct an auxiliar function in Haskell that, for example: let’s $A$ be a matrix such as:
returns me a boolean if there is, at least, a triple followed tens list that are diagonal, thus:
*Main> ((10,2,3,4),(5,10,10,8),(9,10,10,12),(10,14,15,16)) result: True
because in the matrix above we have three 10’s in main diagonal and three 10’s in the other diagonal (in this case, both diagonals are main and secondary, respectively. But it doesn’t have to be like that ) This code calculates the main diagonal of a matrix:
diagonal :: ((Int)) -> (Int) diagonal () = () diagonal (x:xs) = head x : diagonal (map tail xs)
but i need to solve it for any diagonal and no necessarily for square matrix.
I also made a function to group 3 by 3, but i don’t know how to “connect” with the previous idea:
group3in3:: Int -> (a) -> ((a)) group3in3 _ () = (()) group3in3n n xs |n > 0 = (take n xs) : (group3in3 n (drop n xs)) |otherwise = error "Error"
I don’t have a lot of experience with Haskell. Any help would be appreciated.