I need transpose an array from rows into cols and cols into rows
def mtrx = [
[1,2,3],
[4,5,6]
]
//mtrx.anyMethod()
//expected result
//[[1,4],[2,5],[3,6]]
Do you know a direct method from it?
I don't know a Groovy method that transposes this case; if you know another way to transpose please tell me it.
Groovy lists have a transpose()
method:
def transposed = mtrx.transpose()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With