On Friday, 10 February 2017 at 09:34:39 UTC, berni wrote:
On Friday, 10 February 2017 at 09:25:04 UTC, Daniel Kozak wrote:
Now I tried this with a named instead of a magic constant e.g.
immutable VALUE=-1;
arr.each!"a[]=VALUE";
And it doesn't work anymore. I've no clue, why... Can you
help
On Friday, 10 February 2017 at 09:25:04 UTC, Daniel Kozak wrote:
Now I tried this with a named instead of a magic constant e.g.
immutable VALUE=-1;
arr.each!"a[]=VALUE";
And it doesn't work anymore. I've no clue, why... Can you help
me?
Because it does not see VALUE, you need to use delegate
On Friday, 10 February 2017 at 09:03:16 UTC, berni wrote:
Now I tried this with a named instead of a magic constant e.g.
immutable VALUE=-1;
arr.each!"a[]=VALUE";
And it doesn't work anymore. I've no clue, why... Can you help
me?
each is a template. As per the template documentation [1],
Dne 10.2.2017 v 10:03 berni via Digitalmars-d-learn napsal(a):
On Tuesday, 7 February 2017 at 19:06:22 UTC, berni wrote:
auto arr = uninitializedArray!(int[][])(ROWS,COLS);
arr.each!"a[]=-1";
This looks like what I was looking for. At least I think I understand
what's going on here. The othe
On Tuesday, 7 February 2017 at 19:06:22 UTC, berni wrote:
auto arr = uninitializedArray!(int[][])(ROWS,COLS);
arr.each!"a[]=-1";
This looks like what I was looking for. At least I think I
understand what's going on here. The other two suggestions are
beyond my scope yet, but I'll come back, w
auto arr = uninitializedArray!(int[][])(ROWS,COLS);
arr.each!"a[]=-1";
This looks like what I was looking for. At least I think I
understand what's going on here. The other two suggestions are
beyond my scope yet, but I'll come back, when I improved on my D
skills. Thanks for your replies.
On Sunday, 5 February 2017 at 20:33:06 UTC, berni wrote:
With X not known at compile time:
auto arr = new int[][](X,X);
for (int i=0;i
Is there anything better for this? I mean, the program will
fill the array with zeroes, just to overwrite all of them with
-1. That's wasted execution time a
On 02/05/2017 12:33 PM, berni wrote:
With X not known at compile time:
auto arr = new int[][](X,X);
for (int i=0;i
Is there anything better for this? I mean, the program will fill the
array with zeroes, just to overwrite all of them with -1. That's wasted
execution time and doesn't feel D-ish
One another way is use something like this:
import std.array, std.algorithm, std.stdio;
auto arr = uninitializedArray!(int[][])(ROWS,COLS);
arr.each!"a[]=-1";
writeln(arr);
Dne 6. 2. 2017 8:21 PM napsal uživatel "berni via Digitalmars-d-learn" <
digitalmars-d-learn@puremagic.com>:
> On Sunday, 5
On Sunday, 5 February 2017 at 21:14:33 UTC, Daniel Kozak wrote:
http://stackoverflow.com/questions/24600796/d-set-default-value-for-a-struct-member-which-is-a-multidimensional-static-arr/24754361#24754361
Dne 5.2.2017 v 21:33 berni via Digitalmars-d-learn napsal(a):
With X not known at compile
http://stackoverflow.com/questions/24600796/d-set-default-value-for-a-struct-member-which-is-a-multidimensional-static-arr/24754361#24754361
Dne 5.2.2017 v 21:33 berni via Digitalmars-d-learn napsal(a):
With X not known at compile time:
auto arr = new int[][](X,X);
for (int i=0;i
Is there an
With X not known at compile time:
auto arr = new int[][](X,X);
for (int i=0;i
Is there anything better for this? I mean, the program will fill
the array with zeroes, just to overwrite all of them with -1.
That's wasted execution time and doesn't feel D-ish to me.
12 matches
Mail list logo