Anonymous user
Matrix transposition: Difference between revisions
m
→{{header|JavaScript}}: refactoring
m (→{{header|JavaScript}}: don't need to explicitly call toString()) |
m (→{{header|JavaScript}}: refactoring) |
||
Line 475:
=={{header|JavaScript}}==
{{works with|SpiderMonkey}} for the <code>print()</code> function
<lang javascript>function Matrix(ary) {
this.mtx = ary
this.height = ary.length;
this.width = ary[0].length;
}
s.push(
for (var j = 0; j < this.height; j++) {▼
}
transposed[i][j] = this.mtx[j][i];▼
Matrix.prototype.transpose = function() {
transposed[i] = [];
}
return new Matrix(transposed);▼
▲ var s = []
▲ for (var i = 0; i < this.mtx.length; i++)
▲ return s.join("\n");
}
}
|