I am trying to convert a list to an array (list of lists) from a function that receives an Int (i) that is a counter that always starts at 0, another Int (n) that is the length of each row and the list that I have to convert to matrix.
crearLdL :: (Int, Int, [Int]) -> [[Int]]
crearLdL (i, n, ([])) = []
crearLdL (i, n, (x:y)) = if (i < n) then [x] : crearLdL (i+1, n, (y))
else [] ++ crearLdL (0, n, (x:y))
This gives me the way out:
[[1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12],[13],[14],[15],[16],[17],[18]]
when it should be something like:
[[1,2,3,4,5,6],[7,8,9,10,11,12],[13,14,15,16,17,18]]
if n is 6
Does anyone have any idea what I might be failing? I tried several things and found no solution.
Thanks