On Tuesday, 13 March 2018 at 12:09:04 UTC, jmh530 wrote:
On Tuesday, 13 March 2018 at 10:39:29 UTC, 9il wrote:
On Tuesday, 13 March 2018 at 05:36:06 UTC, J-S Caux wrote:

Your suggestion [4] that matrix[i] returns a Vec is perhaps too inflexible. What one needs sometimes is to return a row, or a column of a matrix, so a notation like matrix[i, ..] or matrix[.., j] returning respectively a row or column would be useful.

auto row = matrix[i]; // or matrix[i, 0 .. $];
auto col = matrix[0 .. $, j];

Some kind of improvement that replaces 0 .. $ with some shorter syntax has been brought up in the past.

What I have settled on is Row(x,2), which returns a range that works with foreach. I tried x[_,2] to return Row(x,2) but didn't like reading it, so I went with x[_all,2] instead. Similarly for Col(x,2) and x[2,_all]. The exact form is bikeshedding and shouldn't make much difference. I use ByRow(x) and ByColumn(x) to iterate over the full matrix.

IME, if you try to mix row-order and column-order, or 0-based indexing and 1-based indexing, it's too complicated to write correct code that interacts with other libraries. I think you need to choose one and go with it.

Reply via email to