select all rows (resp. columns) out of matrix
TheFlyingFiddle
theflyingfiddle at gmail.com
Thu Nov 14 14:25:39 PST 2013
On Thursday, 14 November 2013 at 22:18:44 UTC, TheFlyingFiddle
wrote:
> unittest
> {
> int[][] matrix = new int[][](n,m);
>
> //Getting a collumn is simple.
> int[] collumn0 = matrix[0];
>
> //Getting a row is trickier
> int[] row0;
>
> //Loop over all collumns
> foreach(i; matrix) {
> row0 ~= matrix[i][0];
> }
> }
Sry the way you get rows is wrong.
It should be
int[] row0;
foreach(collumn; matrix)
row0 ~= collumn[0];
and not
> int[] row0;
>
> //Loop over all collumns
> foreach(i; matrix) {
> row0 ~= matrix[i][0];
> }
More information about the Digitalmars-d-learn
mailing list