Re: Key and value with ranges

2023-10-02 Thread christian.koestlin via Digitalmars-d-learn
On Monday, 2 October 2023 at 02:47:37 UTC, Joel wrote: How can I improve this code? Like avoiding using foreach. You could fold into a hash that counts the occurrences like that: ```d import std.uni : toLower; import std.array : split, array; import std.stdio : writeln; import std.algorithm :

Re: Key and value with ranges

2023-10-03 Thread christian.koestlin via Digitalmars-d-learn
On Tuesday, 3 October 2023 at 01:55:43 UTC, Andrey Zherikov wrote: On Monday, 2 October 2023 at 18:46:14 UTC, christian.koestlin wrote: [...] Slightly improved: ```d import std; [...] Thanks .. the thing with ref result is very clever! Should `ref result` be `return result`? Kind regards,

Re: Key and value with ranges

2023-10-03 Thread christian.koestlin via Digitalmars-d-learn
On Tuesday, 3 October 2023 at 20:22:30 UTC, Andrey Zherikov wrote: On Tuesday, 3 October 2023 at 19:57:06 UTC, christian.koestlin wrote: On Tuesday, 3 October 2023 at 01:55:43 UTC, Andrey Zherikov wrote: On Monday, 2 October 2023 at 18:46:14 UTC, christian.koestlin wrote: [...] Slightly

Whats the best way to spawn an external process with vibe and process its stdout and stderr

2023-10-07 Thread christian.koestlin via Digitalmars-d-learn
Recently I wanted to wrap a small d program around an external process and stream its stdout/stderr to the original stdout/stderr of the d program (no other output while the external process is running). I first tried to implement this with vibe's fibers, but after failing first try, I

Re: What are best practices around toString?

2022-10-06 Thread christian.koestlin via Digitalmars-d-learn
On Saturday, 1 October 2022 at 17:50:54 UTC, tsbockman wrote: On Saturday, 1 October 2022 at 10:02:34 UTC, Salih Dincer wrote: On Saturday, 1 October 2022 at 08:26:43 UTC, tsbockman wrote: `StringBuilder` is a utility shared across the entire project: Appender not good enough; at least in

Re: dub install package globally

2022-10-06 Thread christian.koestlin via Digitalmars-d-learn
On Thursday, 6 October 2022 at 07:06:52 UTC, Preetpal wrote: Is there a way to install packages "globally" using dub? For example, when using the node package manager (NPM) you can install a package "globally" (so it is available for the current user from the command line) using the

What are best practices around toString?

2022-09-30 Thread christian.koestlin via Digitalmars-d-learn
Dear Dlang experts, up until now I was perfectly happy with implementing `(override) string toString() const` or something to get nicely formatted (mostly debug) output for my structs, classes and exceptions. But recently I stumbled upon