RosettaCodeData/Task/Matrix-transposition/Objeck/matrix-transposition.objeck
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

31 lines
710 B
Text

bundle Default {
class Transpose {
function : Main(args : String[]) ~ Nil {
input := [[1, 1, 1, 1]
[2, 4, 8, 16]
[3, 9, 27, 81]
[4, 16, 64, 256]
[5, 25, 125, 625]];
dim := input->Size();
output := Int->New[dim[0],dim[1]];
for(i := 0; i < dim[0]; i+=1;) {
for(j := 0; j < dim[1]; j+=1;) {
output[i,j] := input[i,j];
};
};
Print(output);
}
function : Print(matrix : Int[,]) ~ Nil {
dim := matrix->Size();
for(i := 0; i < dim[0]; i+=1;) {
for(j := 0; j < dim[1]; j+=1;) {
IO.Console->Print(matrix[i,j])->Print('\t');
};
'\n'->Print();
};
}
}
}