A recursive transpose removes the first column, then transposes the remaining columns:
transpose :: Matrix a -> Matrix a
transpose [] = []
transpose ([] : _) = []
transpose rows = map head rows : transpose (map tail rows)
The internal recursive calls eventually reach rows of length zero, even though the original input has positive dimensions; the second equation handles this terminating case. Rectangularity ensures that the rows become empty together, so no head or tail is applied to an empty row in the third equation. The output is an matrix with entry . The element type is unrestricted.

Articles by others on the same topic (0)

There are currently no matching articles.