Re: Simplest multithreading example

2017-08-31 Thread Brian via Digitalmars-d-learn
On Friday, 1 September 2017 at 04:43:29 UTC, Ali Çehreli wrote: On 08/31/2017 06:59 PM, Brian wrote: > Hello, I am trying to get the most trivial example of multithreading > working, but can't seem to figure it out. > I want to split a task across threads, and wait for all those tasks to > finish

Re: Simplest multithreading example

2017-08-31 Thread Ali Çehreli via Digitalmars-d-learn
On 08/31/2017 06:59 PM, Brian wrote: > Hello, I am trying to get the most trivial example of multithreading > working, but can't seem to figure it out. > I want to split a task across threads, and wait for all those tasks to > finish before moving to the next line of code. > > The following 2 atte

Re: Simplest multithreading example

2017-08-31 Thread Michael Coulombe via Digitalmars-d-learn
On Friday, 1 September 2017 at 01:59:07 UTC, Brian wrote: Hello, I am trying to get the most trivial example of multithreading working, but can't seem to figure it out. I want to split a task across threads, and wait for all those tasks to finish before moving to the next line of code. The fol

Simplest multithreading example

2017-08-31 Thread Brian via Digitalmars-d-learn
Hello, I am trying to get the most trivial example of multithreading working, but can't seem to figure it out. I want to split a task across threads, and wait for all those tasks to finish before moving to the next line of code. The following 2 attempts have failed : --

Re: std.algorithm.joiner unexpected behavior

2017-08-31 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 31, 2017 at 05:37:20PM -0600, Jonathan M Davis via Digitalmars-d-learn wrote: > On Thursday, August 31, 2017 14:09:55 H. S. Teoh via Digitalmars-d-learn [...] > I know. We've had this argument before. I know. Let's not rehash that. :-) [...] > Even copying ranges in generic code do

Re: Valid File Path

2017-08-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, August 31, 2017 23:23:17 Vino via Digitalmars-d-learn wrote: > On Thursday, 31 August 2017 at 21:59:22 UTC, vino wrote: > > Hi All, > > > > Can you help me what is wrong in the below program, as the > > > > output is empty. > > > > import std.stdio, std.path; > > > > void main () > >

Re: std.algorithm.joiner unexpected behavior

2017-08-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, August 31, 2017 14:09:55 H. S. Teoh via Digitalmars-d-learn wrote: > On Thu, Aug 31, 2017 at 01:34:39PM -0600, Jonathan M Davis via > Digitalmars-d-learn wrote: [...] > > > In general, byLine does not work with other range-based algorithms > > precisely because it reuses the buffer. I

Re: Valid File Path

2017-08-31 Thread Vino via Digitalmars-d-learn
On Thursday, 31 August 2017 at 21:59:22 UTC, vino wrote: Hi All, Can you help me what is wrong in the below program, as the output is empty. import std.stdio, std.path; void main () { version (Windows) { auto Path = `C:\#Users\Admin\Desktop\Script\Test1`; if(!Path.isValidPath) { writeln("P

replace switch for mapping

2017-08-31 Thread EntangledQuanta via Digitalmars-d-learn
Generally one has to use a switch to map dynamic components. Given a set X and Y one can form a switch to map X to Y: switch(X) { case x1 : y1; break; case x1 : y1; } Is there any easier way to do this where one simply specifies the set's rather than having to create a switch dir

Re: Valid File Path

2017-08-31 Thread Cym13 via Digitalmars-d-learn
On Thursday, 31 August 2017 at 21:59:22 UTC, vino wrote: Hi All, Can you help me what is wrong in the below program, as the output is empty. import std.stdio, std.path; void main () { version (Windows) { auto Path = `C:\#Users\Admin\Desktop\Script\Test1`; if(!Path.isValidPath) { writeln("P

Valid File Path

2017-08-31 Thread vino via Digitalmars-d-learn
Hi All, Can you help me what is wrong in the below program, as the output is empty. import std.stdio, std.path; void main () { version (Windows) { auto Path = `C:\#Users\Admin\Desktop\Script\Test1`; if(!Path.isValidPath) { writeln("Path Not Valid");} } } From, Vino.B

Re: Remove all blank lines from a file

2017-08-31 Thread vino via Digitalmars-d-learn
On Thursday, 31 August 2017 at 15:48:31 UTC, Rene Zwanenburg wrote: On Thursday, 31 August 2017 at 14:44:07 UTC, vino wrote: Hi All, Can some provide me a example of how to remove all blank lines from a file. From, Vino.B This one doesn't read the entire file into memory: import std.std

Re: std.algorithm.joiner unexpected behavior

2017-08-31 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 31, 2017 at 01:34:39PM -0600, Jonathan M Davis via Digitalmars-d-learn wrote: [...] > In general, byLine does not work with other range-based algorithms > precisely because it reuses the buffer. I think that it does manage to > work for some, but IMHO, it should have just supported for

Re: writeln() sometimes double prints from main() if I run a thread checking for input?

2017-08-31 Thread Ivan Kazmenko via Digitalmars-d-learn
On Thursday, 31 August 2017 at 14:43:39 UTC, Steven Schveighoffer wrote: Just a thought, but the "double printing" could be a misunderstanding. It could be printing Output\nOutput2, but not getting the 2 out there. No no, it's four lines instead of three. If we change the lines to disjoint s

Re: Deprecation of toUTF16

2017-08-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/31/17 12:12 PM, Andre Pany wrote: Hi, I have some problems to find out what to use instead of the deprecated toUTF16 function. I am calling a shared library written in Delphi. While this coding is working fine (with german ü) import std.utf: toUTF16; wstring ws = toUTF16(s); BSTR bStr =

Re: std.algorithm.joiner unexpected behavior

2017-08-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, August 31, 2017 18:43:40 Jesse Phillips via Digitalmars-d-learn wrote: > On Thursday, 31 August 2017 at 18:26:33 UTC, Sergei Degtiarev > > wrote: > > Hi, > > I tried to create a simple range concatenating several files, > > > > something like this: > > File[] files; > > >

Re: std.algorithm.joiner unexpected behavior

2017-08-31 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Aug 31, 2017 at 06:26:33PM +, Sergei Degtiarev via Digitalmars-d-learn wrote: [...] > File[] files; > > foreach(ln; joiner(files.map!(a => a.byLine))) > writeln(ln); You probably want to use byLineCopy instead. The problem here is that .byLine ret

Re: std.algorithm.joiner unexpected behavior

2017-08-31 Thread Jesse Phillips via Digitalmars-d-learn
On Thursday, 31 August 2017 at 18:26:33 UTC, Sergei Degtiarev wrote: Hi, I tried to create a simple range concatenating several files, something like this: File[] files; foreach(ln; joiner(files.map!(a => a.byLine))) writeln(ln); and I see every fi

std.algorithm.joiner unexpected behavior

2017-08-31 Thread Sergei Degtiarev via Digitalmars-d-learn
Hi, I tried to create a simple range concatenating several files, something like this: File[] files; foreach(ln; joiner(files.map!(a => a.byLine))) writeln(ln); and I see every first line of each file is missing. However, when I do same thing with s

Re: Deprecation of toUTF16

2017-08-31 Thread Andre Pany via Digitalmars-d-learn
On Thursday, 31 August 2017 at 17:22:51 UTC, Kagamin wrote: import std.conv; auto ws=s.to!wstring; Thank you! Kind regards André

Re: Deprecation of toUTF16

2017-08-31 Thread Kagamin via Digitalmars-d-learn
import std.conv; auto ws=s.to!wstring;

Deprecation of toUTF16

2017-08-31 Thread Andre Pany via Digitalmars-d-learn
Hi, I have some problems to find out what to use instead of the deprecated toUTF16 function. I am calling a shared library written in Delphi. While this coding is working fine (with german ü) import std.utf: toUTF16; wstring ws = toUTF16(s); BSTR bStr = SysAllocStringLen(ws.ptr, cast(UINT) ws

Re: Parse tree node allocator

2017-08-31 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 31 August 2017 at 15:43:05 UTC, Per Nordlöw wrote: Which allocator is best suited for allocating tree nodes (all of equal size around 40-60 bytes in size) in one shot and then delete them all in one go? My use case is parse trees. Region Allocator.

Re: Remove all blank lines from a file

2017-08-31 Thread Rene Zwanenburg via Digitalmars-d-learn
On Thursday, 31 August 2017 at 14:44:07 UTC, vino wrote: Hi All, Can some provide me a example of how to remove all blank lines from a file. From, Vino.B This one doesn't read the entire file into memory: import std.stdio; import std.array; import std.algorithm; import std.uni; void mai

Re: Bug in D!!!

2017-08-31 Thread EntangledQuanta via Digitalmars-d-learn
On Thursday, 31 August 2017 at 10:34:14 UTC, Kagamin wrote: On Thursday, 31 August 2017 at 00:49:22 UTC, EntangledQuanta wrote: I've already implemented a half ass library solution. It can be improved alot. Then, by all means, genius!

Parse tree node allocator

2017-08-31 Thread Per Nordlöw via Digitalmars-d-learn
Which allocator is best suited for allocating tree nodes (all of equal size around 40-60 bytes in size) in one shot and then delete them all in one go? My use case is parse trees.

Re: Remove all blank lines from a file

2017-08-31 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 31 August 2017 at 14:44:07 UTC, vino wrote: Hi All, Can some provide me a example of how to remove all blank lines from a file. From, Vino.B Super verbose, but: import std.stdio; import std.file; import std.algorithm.iteration; enum inFilename = "in.txt"; enum outFilename =

Re: Remove all blank lines from a file

2017-08-31 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 31 August 2017 at 14:44:07 UTC, vino wrote: Hi All, Can some provide me a example of how to remove all blank lines from a file. From, Vino.B ubyte[] fileData; ubyte[] writeThis; uint lastP; fileData = readRaw(fileName); foreach(uint p; ubyte b;fileData) { if (b == '\n')

Remove all blank lines from a file

2017-08-31 Thread vino via Digitalmars-d-learn
Hi All, Can some provide me a example of how to remove all blank lines from a file. From, Vino.B

Re: writeln() sometimes double prints from main() if I run a thread checking for input?

2017-08-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/30/17 9:33 AM, Ivan Kazmenko wrote: On Wednesday, 30 August 2017 at 13:24:55 UTC, Ivan Kazmenko wrote: On Wednesday, 30 August 2017 at 10:55:20 UTC, Timothy Foster wrote: import std.stdio, core.thread; void main(){ auto thread = new Thread(&func).start;     writeln("Output");

Re: writeln() sometimes double prints from main() if I run a thread checking for input?

2017-08-31 Thread Ivan Kazmenko via Digitalmars-d-learn
On Wednesday, 30 August 2017 at 13:33:06 UTC, Ivan Kazmenko wrote: Interesting. As to what to do with it, no idea for now. At the very least we can issue a bug report, now that at least two people can reproduce it, so it is unlikely to be environment-dependent. Reported: https://issues.dlan

Re: Output range with custom string type

2017-08-31 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 31 August 2017 at 07:06:26 UTC, Jacob Carlborg wrote: On 2017-08-29 19:35, Moritz Maxeiner wrote: void put(T t) {     if (!store)     {     // Allocate only once for "small" vectors     store = alloc.makeArray!T(8);     if (!store) onO

Re: Transitive const and function pointers/delegates

2017-08-31 Thread Kagamin via Digitalmars-d-learn
It's const(int delegate(char))

Re: Bug in D!!!

2017-08-31 Thread Kagamin via Digitalmars-d-learn
On Thursday, 31 August 2017 at 00:49:22 UTC, EntangledQuanta wrote: I've already implemented a half ass library solution. It can be improved alot.

Re: "Range invalidation" ?

2017-08-31 Thread Mark via Digitalmars-d-learn
On Wednesday, 30 August 2017 at 15:06:12 UTC, Jonathan M Davis wrote: [...] Thank you for the detailed response.

Re: hijack dub test

2017-08-31 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 31 August 2017 at 07:04:13 UTC, Jacob Carlborg wrote: On 2017-08-31 08:41, Nicholas Wilson wrote: My project is a library, but I also need to test it and unit tests won't cut it (external hardware). How do you set up the dub.json to build the library normally but when it is invok

Re: Output range with custom string type

2017-08-31 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-29 19:35, Moritz Maxeiner wrote: void put(T t) {     if (!store)     {     // Allocate only once for "small" vectors     store = alloc.makeArray!T(8);     if (!store) onOutOfMemoryError();     }     else if (length == store.leng

Re: hijack dub test

2017-08-31 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-31 08:41, Nicholas Wilson wrote: My project is a library, but I also need to test it and unit tests won't cut it (external hardware). How do you set up the dub.json to build the library normally but when it is invoked with `dub test` it runs a separate configuration that also inclu