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
Hi I'm trying out D and wanted to try some features cpp doesn't
have yet. So I put together a small json parsing, generating
looking based on reflection. Is there anything wrong with how I'm
working with it in the module?
https://github.com/rharriso/JSONInflater.d
Thanks in advance
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;
?
On 01/18/2016 04:38 PM, Adam D. Ruppe wrote:
On Tuesday, 19 January 2016 at 00:33:21 UTC, Johan Engelen wrote:
Is it possible to do conditional compilation inside an array initializer?
No, but you might break it up:
enum inttable_1 = [1,4];
version(smth)
enum inttable_middle = [5,6];
els
On Tuesday, 19 January 2016 at 00:33:21 UTC, Johan Engelen wrote:
Is it possible to do conditional compilation inside an array
initializer?
No, but you might break it up:
enum inttable_1 = [1,4];
version(smth)
enum inttable_middle = [5,6];
else
enum inttable_middle = [];
enum inttable_
Is it possible to do conditional compilation inside an array
initializer? Something like this:
int[] inttable =
[
1,
4,
version(smth) { // <--- does not compile
5,
6,
}
8,
1345
];
(real world case:
https://github.com/ldc-developers/ldc/blob/merge-2.069/ddmd/idgen.d#L279)
I'm playing with the example below. I noticed a few things.
1. The ndslice didn't support the extra index, i, in the foreach,
so had to add extra i,j.
2. I couldn't figure out a way to use sliced on the original 'a'
array. Is slicing only available on 1 dim arrays?
3. Sliced parameter order is
On 01/18/2016 02:08 PM, Voitech wrote:
> alias Element =Algebraic!(real,string);
>
> i will get:
>
> Cannot store a int in a VariantN!(16LU, real, string)
Are you really storing a 'real' or a 'string'? (The default floating
type in D is double, not real.) The following compiles and works as
ex
On Monday, 18 January 2016 at 21:15:51 UTC, Chris Wright wrote:
On Mon, 18 Jan 2016 19:19:22 +, Voitech wrote:
Hi. I'm trying to parse an simple string expression to
something like Element array. Each Element can have a value of
unknown type, which will be further combined and calculated t
On Mon, 18 Jan 2016 19:19:22 +, Voitech wrote:
> Hi. I'm trying to parse an simple string expression to something like
> Element array. Each Element can have a value of unknown type, which will
> be further combined and calculated to let say real/double/float value,
> no mather.
In Java, Elem
On 2016-01-18 19:11, Russel Winder via Digitalmars-d-learn wrote:
It seems DStep is producing somewhat strange D from complicated C
unions.
Please report any issues to [1] with a test case. C code, expected D
code, actual D code.
[1] https://github.com/jacob-carlborg/dstep/issues
--
/Jacob
Here's what I suggest:
alias T = int;
class VariableLengthClass {
private:
string someMember;
size_t length_;
T[0] data_;
public:
static make(Args...)(size_t length, Args args) {
static assert(
typeof(this).init.data_.offsetof ==
__traits(classInstanceSize
Hi. I'm trying to parse an simple string expression to something
like Element array. Each Element can have a value of unknown
type, which will be further combined and calculated to let say
real/double/float value, no mather.
In Java i had something like generics and this could be
implemented
On Monday, 18 January 2016 at 15:15:46 UTC, Dennis Croft wrote:
I'm trying to organize a large amount of simple data into
manageable parcels of information that I can access
efficiently. What I want to do is bake a static array into a
class but be allowed to do the banking at runtime (because I
On Mon, 2016-01-18 at 18:17 +0100, anonymous via Digitalmars-d-learn
wrote:
> On 18.01.2016 18:10, Russel Winder via Digitalmars-d-learn wrote:
> > So this is an error?
> >
> > union flob {
> > ulong data;
> > struct thingy {
> > uint data;
> > uint bits;
> > }
On 18.01.2016 18:10, Russel Winder via Digitalmars-d-learn wrote:
So this is an error?
union flob {
ulong data;
struct thingy {
uint data;
uint bits;
}
thingy burble;
};
because you cannot have a union field with a name that is als
So this is an error?
union flob {
ulong data;
struct thingy {
uint data;
uint bits;
}
thingy burble;
};
because you cannot have a union field with a name that is also the name
of a struct field defined within the union.
--
Russel
I'm trying to organize a large amount of simple data into
manageable parcels of information that I can access efficiently.
What I want to do is bake a static array into a class but be
allowed to do the banking at runtime (because I want each array
to be a different fixed length). Barring that,
On 19/01/16 2:47 AM, Maik Klein wrote:
I have also asked this question here
https://stackoverflow.com/questions/34838742/weak-references-or-pointers
But I try to word it differently.
I have a game with GameObjects, a system manages those GameObjects.
GameObjects can hold a pointer/reference to
I have also asked this question here
https://stackoverflow.com/questions/34838742/weak-references-or-pointers
But I try to word it differently.
I have a game with GameObjects, a system manages those
GameObjects. GameObjects can hold a pointer/reference to each
other.
But at one point a Game
On Sunday, January 17, 2016 14:43:26 Borislav Kosharov via Digitalmars-d-learn
wrote:
> Seeing that TickDuration is being deprecated and that I should
> use Duration instead, I faced a problem. I need to get total
> seconds like a float. Using .total!"seconds" returns a long and
> if the duration
On Monday, 18 January 2016 at 05:20:42 UTC, WhatMeWorry wrote:
I can workaround the problem but it seems like a kludge; I'm
curious about the subtleties of this problems.
You can't have a variable with the same name as a module because
they're both symbols with the same name. It messes up the
35 matches
Mail list logo