Matrix transposition: Difference between revisions

→‎{{header|Haskell}}: Added a variant expressed in terms of Data.Matrix
No edit summary
(→‎{{header|Haskell}}: Added a variant expressed in terms of Data.Matrix)
Line 2,283:
[[1,4,7],[2,5,8],[3,6,9]]
</pre>
 
or, in terms of Data.Matrix:
 
<syntaxhighlight lang="haskell">import Data.Matrix
 
main :: IO ()
main =
let matrix = fromList 3 4 [1 ..]
in print matrix >> print (transpose matrix)</syntaxhighlight>
{{Out}}
<pre>┌ ┐
│ 1 2 3 4 │
│ 5 6 7 8 │
│ 9 10 11 12 │
└ ┘
┌ ┐
│ 1 5 9 │
│ 2 6 10 │
│ 3 7 11 │
│ 4 8 12 │
└ ┘</pre>
 
===With Numeric.LinearAlgebra===
9,655

edits