Matrix transposition: Difference between revisions
Content added Content deleted
Line 277: | Line 277: | ||
=={{header|Groovy}}== |
=={{header|Groovy}}== |
||
The GroovyCollections class provides a transpose method which will do the work for us: |
|||
<lang groovy>def matrix = [ [ 1, 2, 3, 4 ], |
|||
[ 5, 6, 7, 8 ] ] |
|||
matrix.each { println it} |
|||
println() |
|||
def transpose = GroovyCollections.transpose(matrix) |
|||
transpose.each { println it }</lang> |
|||
Output: |
|||
<pre>[1, 2, 3, 4] |
|||
[5, 6, 7, 8] |
|||
[1, 5] |
|||
[2, 6] |
|||
[3, 7] |
|||
[4, 8]</pre> |
|||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||