Better than "Clock.currStdTime()/10000000"

2017-02-15 Thread berni via Digitalmars-d-learn
I need to measure time elapsed in seconds, like this: auto start = Clock.currStdTime(); // some stuff auto stop = Clock.currStdTime(); auto duration = (stop-start)/1000; This works, but I wonder if there is something better that using the magic constant 1000. I read about 10.secs

Re: Initialization of dynamic multidimensional array

2017-02-10 Thread berni via Digitalmars-d-learn
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

Re: Initialization of dynamic multidimensional array

2017-02-10 Thread berni via Digitalmars-d-learn
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

Re: Initialization of dynamic multidimensional array

2017-02-10 Thread berni via Digitalmars-d-learn
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,

Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-10 Thread berni via Digitalmars-d-learn
$> dmd Special/special.d Common/common.o Special/special.d(4): Error: module common is in file 'common.d' which cannot be read import path[0] = /usr/include/dmd/phobos import path[1] = /usr/include/dmd/druntime/import This is not a linker error. It's a compiler error. You need common.d for

Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread berni via Digitalmars-d-learn
On Thursday, 9 February 2017 at 19:10:55 UTC, Daniel Kozak wrote: Dne 9.2.2017 v 17:20 berni via Digitalmars-d-learn napsal(a): [...] Ah ok, I understand. So calling with "dmd Special/special.d Common/common.d" works. But when I compile common.d to common.o (with dmd -

Re: Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread berni via Digitalmars-d-learn
dmd only compiles in the files you actually pass to it. rdmd will try to find the required files automatically. Since you didn't pass the file with the function to dmd, it knows it exists, but leaves it out of the final link (it assumes it might come from a library or something). That's why

Strange behaviour of rdmd vs. dmd concerning main function

2017-02-09 Thread berni via Digitalmars-d-learn
I've got two source files in two directories: Common/common.d module common; import std.stdio; int main(string[] args) { Foo foo = cast(Foo)Object.factory("special.Bar"); foo.do_something(); return 0; } abstract class Foo { abstract void do_something(); } Special/special.d

Re: Initialization of dynamic multidimensional array

2017-02-07 Thread berni via Digitalmars-d-learn
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.

Re: Initialization of dynamic multidimensional array

2017-02-06 Thread berni via Digitalmars-d-learn
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

Initialization of dynamic multidimensional array

2017-02-05 Thread berni via Digitalmars-d-learn
With X not known at compile time: auto arr = new int[][](X,X); for (int i=0;i

<    1   2