On 11/14/2013 02:18 PM, TheFlyingFiddle wrote:
On Thursday, 14 November 2013 at 22:06:28 UTC, seany wrote:
How do I access All rows (resp. columns ) of a Matrix /
multidimensional array?

In scilab, you write array_var(:,row_index), colon meaning all
columns, at that particular row given by row index will be selected.

can you, forexample, in D, write, array_var[0][] to select all
elements (columns, in this case i believe?) of array_var[0] ?

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];
   }
}



transversal() is useful too: :)

  http://dlang.org/phobos/std_range.html#transversal

Ali

Reply via email to