Multidimensional slice

Nekroze nekroze at eturnilnetwork.com
Wed Dec 19 03:59:22 PST 2012


On Wednesday, 19 December 2012 at 10:33:38 UTC, Rafael wrote:
> On Wednesday, 19 December 2012 at 10:25:23 UTC, Rafael wrote:
>> On Wednesday, 19 December 2012 at 10:17:28 UTC, Nekroze wrote:
>>> On Wednesday, 19 December 2012 at 09:58:37 UTC, Rafael wrote:
>>>> //Then I want to do something like
>>>> x = S[0..$, 1]; //get column
>>>> S[0..$, 2] = A[0..$, 2]; //get and set column
>>>> auto B = A[0..10, 0..10]; //get submatrix block of matrix A
>>>
>>> Warning the following is my total noob opinion.
>>>
>>> Instead of using [0..$,2] for example, try [0..$][2] and see 
>>> how that works out. D doesn't use multiple indexes in the 
>>> same [] section as far as i know so give that a go.
>>
>> Yes, this is the first solution, that come to mind. But there 
>> are some problems in that way. Firs of them (but not main) - 
>> not uniform syntax. The more important: which should result 
>> operation Matrix[0..$] in that case?
>
> Not uniform syntax in this case is the one simple thing:
> A[i, j]; // get the a_ij
> A[i][j]; // get the a_ij
>
> but I like a first variant!

Sorry it may be my lack of knowledge or something but no one else 
seems to be responding so i will keep trying to help as best i 
can.

What do you mean by uniform syntax? do you mean you want the 
syntax to be the same as in other languages? because as it says 
on the dlang page for arrays under rectangular arrays it says 
that a[i][j] is just the way that D does it where as in c++ is 
a[i, j] but that's just one of the differences between languages 
that cant be avoided as far as i know.


More information about the Digitalmars-d-learn mailing list