On Thursday, 21 January 2016 at 01:36:21 UTC, Nemo wrote:
I don't remember where I saw it, but actually, in static
multi-dimensional arrays, arr[0][1] is next to arr[0][0] in
memory. You can see it with:
void main () {
ubyte [7][5] arr;
import std.stdio : writeln;
writeln ( & arr[0][0],
On Tuesday, 19 January 2016 at 20:39:37 UTC, tsbockman wrote:
On Tuesday, 19 January 2016 at 19:14:30 UTC, alb wrote:
[...]
One other thing you may want to keep in mind when working on
this kind of thing - when you loop over a multi-dimensional
array, the order matters.
For large arrays
On Tuesday, 19 January 2016 at 19:14:30 UTC, alb wrote:
So guys: Ali, Mike Parker and tsbockman thanks for all your
explanation, in fact looking now I and after making some tests
I really got it.
So:
int[2]a1; // Array of 2 elements of type int
int[2][5] a2; // Array of 2 elements o
So guys: Ali, Mike Parker and tsbockman thanks for all your
explanation, in fact looking now I and after making some tests I
really got it.
So:
int[2]a1; // Array of 2 elements of type int
int[2][5] a2; // Array of 2 elements of type int divided in 5
rows
writeln(a2[0]); // = a
On Tuesday, 19 January 2016 at 14:58:51 UTC, tsbockman wrote:
Anyway, I'll give it a rest now. I thought this way of looking
at it would make things easier to understand, but I guess not...
In my experience, it's focusing on the types in the D array
syntax, rather than the actual ordering, th
On Tuesday, 19 January 2016 at 13:00:19 UTC, Mike Parker wrote:
Newcomers to D tend to think in terms of C when they declare
arrays, so the confusion comes when they find out they have to
index it in a way that is the reverse of what they expect. Yes,
it's because the declaration syntax is diff
On Tuesday, 19 January 2016 at 08:27:56 UTC, tsbockman wrote:
The only relevant difference between the two, is that the order
of the row and column specification is swapped in *the
declaration*, not when indexing.
Newcomers to D tend to think in terms of C when they declare
arrays, so the co
On Tuesday, 19 January 2016 at 07:46:59 UTC, Mike Parker wrote:
It's not that he's seeing them as special, it's just that
indexing them in D is different than doing so in C or C++. It
trips a lot of people up.
No, the difference is actually in C/C++ 's declaration syntax;
the way that indexin
On Tuesday, 19 January 2016 at 07:32:22 UTC, tsbockman wrote:
That's because you're stuck in the mindset that 2d arrays are
somehow *special*. If I do this:
It's not that he's seeing them as special, it's just that
indexing them in D is different than doing so in C or C++. It
trips a lot
On Tuesday, 19 January 2016 at 07:35:34 UTC, tsbockman wrote:
By substitution, we expect `b[0]` to be equal to `(a[4])[9]`.
Apparently I need to get more sleep:
By substitution, we expect `b[9]` to be equal to `(a[4])[9]`.
On Tuesday, 19 January 2016 at 07:32:22 UTC, tsbockman wrote:
Now let's define `Row`:
alias Row = int[10];
Row[5] a;
const b = a[9];
const int = c = b[4];
Of what type is `b` now? Of course it is still `Row`.
By substitution, we expect `b[0]` to be equal to `(a[9])[4]`.
Sigh. I should proof-
On Tuesday, 19 January 2016 at 07:21:39 UTC, albert00 wrote:
On Tuesday, 19 January 2016 at 04:50:18 UTC, tsbockman wrote:
On Tuesday, 19 January 2016 at 03:20:30 UTC, albert00 wrote:
[...]
... what you're making is an array *of arrays*:
Maybe I was misunderstood, because in fact that is wh
On Tuesday, 19 January 2016 at 07:21:39 UTC, albert00 wrote:
Again seems a bit strange "FOR ME" since I declare in one way
and access the other way.
albert.
That's because you're stuck in the mindset that 2d arrays are
somehow *special*. If I do this:
Row[5] a;
const b = a[4];
Of what typ
On Tuesday, 19 January 2016 at 07:19:54 UTC, Ali Çehreli wrote:
...
Well anyway thanks for your help. For now I'll just think the
otherwise. :)
Albert.
On Tuesday, 19 January 2016 at 04:50:18 UTC, tsbockman wrote:
On Tuesday, 19 January 2016 at 03:20:30 UTC, albert00 wrote:
[...]
... what you're making is an array *of arrays*:
Maybe I was misunderstood, because in fact that is what I was
making an array of arrays, but my problem in fact wa
On 01/18/2016 11:12 PM, Albert00 wrote:
> On Tuesday, 19 January 2016 at 05:32:07 UTC, Ali Çehreli wrote:
>
> Ali, look what you said:
>
>> For example, the following is a row with two columns:
>>
>> int[2]
>
> Then you said:
>
>> So, in order to get 1 row of 2 columns, you would write
>>
>>
On Tuesday, 19 January 2016 at 05:32:07 UTC, Ali Çehreli wrote:
Ali, look what you said:
For example, the following is a row with two columns:
int[2]
Then you said:
So, in order to get 1 row of 2 columns, you would write
int[2][1]
So the first pair of square-brackets is the colu
On 01/18/2016 07:20 PM, albert00 wrote:
> It's strange since I was declaring int[1][2] (1 row / 2 columns) and
> then accessing as:
>
> arr2[0][0] = 1;
> arr2[1][0] = 2;
>
> Seems like 2 rows and 1 column. This makes sense?
Yes, it makes sense and its consistent. This is one of many li
On Tuesday, 19 January 2016 at 03:20:30 UTC, albert00 wrote:
[...]
You're not really creating a rectangular array - what you're
making is an array *of arrays*:
int[10][5] a; // An array of 5 (int[10])
writeln(typeof(a).stringof); // int[10][5]
writeln(typeof(a[4]).stringof);// int[
Well maybe it was my fault, but anyway, here's a small example of
what I was working on:
void main(){
// Array 1
int[2][2] arr1;
arr1[0][0] = 1;
arr1[0][1] = 2;
arr1[1][0] = 3;
arr1[1][1] = 4;
// Array 2
int[1][2] arr2;
On Tuesday, 19 January 2016 at 02:54:03 UTC, cym13 wrote:
int[2][5] arr;
?
How is that not rectangular? It's sounds like you're confusing
it with "square".
Ow my problem is:
int[2][2] arr; // This works
int[2][5] arr; // This not working
And I'd like to create the former.
On Tuesday, 19 January 2016 at 02:47:04 UTC, albert wrote:
Hello,
I was looking over
http://dlang.org/spec/arrays.html#rectangular-arrays:
And I've found that D multidimensional arrays are Rectangular,
so it's impossible to create non-rectangular multidimensional
static array like:
int[2]
Hello,
I was looking over
http://dlang.org/spec/arrays.html#rectangular-arrays:
And I've found that D multidimensional arrays are Rectangular, so
it's impossible to create non-rectangular multidimensional static
array like:
int[2][5] arr;
?
23 matches
Mail list logo