Re: How to print unicode characters (no library)?

2021-12-26 Thread rempas via Digitalmars-d-learn
On Sunday, 26 December 2021 at 23:57:47 UTC, H. S. Teoh wrote: In some Unix terminals, backspace + '_' causes a character to be underlined. So it's really a mini VM, not just pure data. So yeah, the good ole ASCII days never happened. :-D T How can you do that? I'm trying to print the codes

Re: How to print unicode characters (no library)?

2021-12-26 Thread rempas via Digitalmars-d-learn
On Sunday, 26 December 2021 at 21:22:42 UTC, Adam Ruppe wrote: write just transfers a sequence of bytes. It doesn't know nor care what they represent - that's for the receiving end to figure out. Oh, so it was as I expected :P You are mistaken. There's several exceptions, utf-16 can come

Re: How to print unicode characters (no library)?

2021-12-26 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Dec 26, 2021 at 11:45:25PM +, max haughton via Digitalmars-d-learn wrote: [...] > I think that mental model is pretty good actually. Maybe a more > specific idea exists, but this virtual machine concept does actually > explain to the new programmer to expect dragons - or at least that

Re: How to print unicode characters (no library)?

2021-12-26 Thread max haughton via Digitalmars-d-learn
On Sunday, 26 December 2021 at 21:22:42 UTC, Adam Ruppe wrote: On Sunday, 26 December 2021 at 20:50:39 UTC, rempas wrote: [...] write just transfers a sequence of bytes. It doesn't know nor care what they represent - that's for the receiving end to figure out. [...] You are mistaken.

Re: How to print unicode characters (no library)?

2021-12-26 Thread Adam Ruppe via Digitalmars-d-learn
On Sunday, 26 December 2021 at 20:50:39 UTC, rempas wrote: I want to do this without using any library by using the "write" system call directly with 64-bit Linux. write just transfers a sequence of bytes. It doesn't know nor care what they represent - that's for the receiving end to figure

How to print unicode characters (no library)?

2021-12-26 Thread rempas via Digitalmars-d-learn
Hi! I'm trying to print some Unicode characters using UTF-8 (char), UTF-16 (wchar) and UTF-32 (dchar). I want to do this without using any library by using the "write" system call directly with 64-bit Linux. Only the UTF-8 solution seems to be working as expected. The other solutions will not

Re: First time using Parallel

2021-12-26 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 26 December 2021 at 15:36:54 UTC, Bastiaan Veelo wrote: On Sunday, 26 December 2021 at 15:20:09 UTC, Bastiaan Veelo wrote: So if you use `workerLocalStorage` ... you'll get your output in order without sorting. Scratch that, I misunderstood the example. It doesn't solve ordering.

Re: Double bracket "{{" for scoping static foreach is no longer part of D

2021-12-26 Thread Era Scarecrow via Digitalmars-d-learn
On Wednesday, 22 December 2021 at 16:30:06 UTC, data pulverizer wrote: On Wednesday, 22 December 2021 at 16:10:42 UTC, Adam D Ruppe wrote: So OUTSIDE a function, static foreach() {{ }} is illegal because a plain {} is illegal outside a function. But INSIDE a function, static foreach() {{ }}

Re: First time using Parallel

2021-12-26 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 26 December 2021 at 15:20:09 UTC, Bastiaan Veelo wrote: So if you use `workerLocalStorage` to give each thread an `appender!string` to write output to, and afterwards write those to `stdout`, you'll get your output in order without sorting. Scratch that, I misunderstood the

Re: First time using Parallel

2021-12-26 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 26 December 2021 at 11:24:54 UTC, rikki cattermole wrote: I would start by removing the use of stdout in your loop kernel - I'm not familiar with what you are calculating, but if you can basically have the (parallel) loop operate from (say) one array directly into another then you

Re: First time using Parallel

2021-12-26 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 26 December 2021 at 06:10:03 UTC, Era Scarecrow wrote: [...] ```d foreach(value; taskPool.parallel(range) ){code} ``` [...] Now said results are out of order [...] So I suppose, is there anything I need to know? About shared resources or how to wait until all threads are

Re: How to gets multi results using tuple in D?

2021-12-26 Thread zoujiaqing via Digitalmars-d-learn
On Thursday, 23 December 2021 at 08:56:36 UTC, WebFreak001 wrote: On Thursday, 23 December 2021 at 08:33:17 UTC, zoujiaqing wrote: C++ Code: ```cpp std::tuple DoIt() { return {false, 0, 0, "Hello"}; } auto [r1, r2, r3, r4] = DoIt(); if (r1 == false) ``` D Code: ```D Tuple!(bool, int,

Re: First time using Parallel

2021-12-26 Thread rikki cattermole via Digitalmars-d-learn
On 27/12/2021 12:10 AM, max haughton wrote: I would start by removing the use of stdout in your loop kernel - I'm not familiar with what you are calculating, but if you can basically have the (parallel) loop operate from (say) one array directly into another then you can get extremely good

Re: First time using Parallel

2021-12-26 Thread max haughton via Digitalmars-d-learn
On Sunday, 26 December 2021 at 06:10:03 UTC, Era Scarecrow wrote: This is curious. I was up for trying to parallelize my code, specifically having a block of code calculate some polynomials (*Related to Reed Solomon stuff*). So I cracked open std.parallel and looked over how I would manage