definition of transpose

Doug McIlroy doug at
Sat Dec 1 22:33:18 CET 2012

The description of "transpose" in Haskell 2010, section 20.2,
does not tell how unequal-length rows are treated.
A more revealing example would help, perhaps something like
	transpose [[1,2],[3],[4,5,6]] == [[1,3,4],[2,5],[6]]

Notice that the usual identities, (transpose x)!!i!!j==x!!j!!i
and transpose.transpose==id do not hold unless row lengths
are monotone non-increasing.

[It might be well to restrict the input so the identities do hold.
This would simplify explanation, implementation, and proofs. Has
anybody found transpose useful outside this domain?]

Doug McIlroy

More information about the Haskell-prime mailing list