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:
The Groovy extensions ti the List class provides a transpose method:
<lang groovy>def matrix = [ [ 1, 2, 3, 4 ],
<lang groovy>def matrix = [ [ 1, 2, 3, 4 ],
[ 5, 6, 7, 8 ] ]
[ 5, 6, 7, 8 ] ]
Line 283: Line 283:
matrix.each { println it }
matrix.each { println it }
println()
println()
def transpose = GroovyCollections.transpose(matrix)
def transpose = matrix.transpose()


transpose.each { println it }</lang>
transpose.each { println it }</lang>