Re: Function to print a diamond shape

2014-03-22 Thread Ali Çehreli
On 03/22/2014 06:03 PM, Jay Norwood wrote: > derr.writefln("time: ", sw.peek().msecs, "[ms]"); Cool. stderr should work too: stderr.writefln(/* ... */); Ali

Re: Function to print a diamond shape

2014-03-22 Thread Jay Norwood
I decided to redirect stdout to nul and print the stopwatch messages to stderr. So, basically like this. import std.stdio; import std.datetime; import std.cstream; StopWatch sw; sw.start(); measured code sw.stop(); derr.writefln("time: ", sw.peek().msecs, "[ms]"); Then, windows results compa

Re: shouldn't this work? / how to make it work?

2014-03-22 Thread anonymous
On Saturday, 22 March 2014 at 22:54:15 UTC, captaindet wrote: pls see example code below. the two 'test' templates work fine by themselves. if, however, in the same module, the eponymous template does not work anymore. instead the compiler seems to try instantiating the variadic template. a

shouldn't this work? / how to make it work?

2014-03-22 Thread captaindet
pls see example code below. the two 'test' templates work fine by themselves. if, however, in the same module, the eponymous template does not work anymore. instead the compiler seems to try instantiating the variadic template. a) why? for how i understand it, this should not happen as o they

Re: Function to print a diamond shape

2014-03-22 Thread Jay Norwood
The computation times of different methods can differ a lot. How do you suggest to measure this effectively without the overhead of the write and writeln output? Would a count of 11 and stubs like below be reasonable, or would there be something else that would prevent the optimizer fr

Re: More updated question about Sleep/msleep/usleep

2014-03-22 Thread Adam D. Ruppe
This will work: import core.thread; void main() { Thread.sleep(5.seconds); } sleep is a member of Thread, but it is static so you can easily call it to sleep the current thread. The argument is a Duration, which is most easily constructed with the .seconds, .msecs, .minutes, etc. help

Re: More updated question about Sleep/msleep/usleep

2014-03-22 Thread Adam D. Ruppe
import core.thread; void main() { }

More updated question about Sleep/msleep/usleep

2014-03-22 Thread BeschBesch
Hello, I know there are severel threads concerning "Wait", "Pause", "Sleep", a.s.o but most of them were created in 2007 or similiar. It seems D has changed a lot because when I try to call sleep/msleep (example), the compiler cannot find it (ERROR: undefined indentifier). import std.stdio;

Re: to! converting 1D to 2D array

2014-03-22 Thread Marc Schütz
On Friday, 14 March 2014 at 19:24:21 UTC, Chris Williams wrote: In D, an array is a struct (struct Array), with an address and a length value. A multi-dimensional array is an Array with an address pointing to an array of Arrays. So with an int[2][2] array, you have a layout like: @1000 Array(

Re: Ada-Style Range Types with Value Range Propagation in Arithmetic

2014-03-22 Thread bearophile
Nordlöw: I cracked it: This is important stuff. So if you find that you can't do something in D, consider asking for it in the main D newsgroup and in Bugzilla. Bye, bearophile

Re: BitArray in custom class & initialize it in ctor with arguments

2014-03-22 Thread bearophile
MarisaLovesUsAll: Hi! I need to use array of bits in my custom class. I tried to add std.bitmanip.BitArray as field, but got a strange error. What am I doing wrong? import std.bitmanip; class Scene { BitArray collisionMap; this(int w, int h) { collisionMap.init([0,0,0]

Re: Ranges/algorithms for aggregation

2014-03-22 Thread bearophile
Luís Marques: It would swap elements, like sort, so it doesn't need to put them anywhere, just permute them. The advantage is this: Input: [7, 3, 7, 1, 1, 1, 1] Output sort: [1, 1, 1, 1, 3, 7, 7] Output groupSort: [3, 7, 7, 1, 1, 1, 1] I think to swap items it must know where to swap them to

BitArray in custom class & initialize it in ctor with arguments

2014-03-22 Thread MarisaLovesUsAll
Hi! I need to use array of bits in my custom class. I tried to add std.bitmanip.BitArray as field, but got a strange error. What am I doing wrong? import std.bitmanip; class Scene { BitArray collisionMap; this(int w, int h) { collisionMap.init([0,0,0]); } } C:\D\dmd2