Re: array setting : Whats going in here?

2023-10-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, October 7, 2023 10:59:47 AM MDT claptrap via Digitalmars-d-learn wrote: > On Saturday, 7 October 2023 at 00:49:39 UTC, H. S. Teoh wrote: > > On Sat, Oct 07, 2023 at 12:00:48AM +, claptrap via > > Digitalmars-d-learn wrote: > > > > > > When you write `foo[]` you're taking a slice

Re: is there a way to use sumtype in `switch/case` (with multiple statements)? or how can I get the `tag` and `storage`?

2023-10-07 Thread mw via Digitalmars-d-learn
On Saturday, 7 October 2023 at 19:30:23 UTC, mw wrote: On Saturday, 7 October 2023 at 19:25:51 UTC, mw wrote: Or how can I get the `tag` and `storage` myself? https://github.com/dlang/phobos/blob/a3f22129dd2a134338ca02b79ff0de242d7f016e/std/sumtype.d#L310 If I add this line to the above

Re: is there a way to use sumtype in `switch/case` (with multiple statements)? or how can I get the `tag` and `storage`?

2023-10-07 Thread mw via Digitalmars-d-learn
On Saturday, 7 October 2023 at 19:25:51 UTC, mw wrote: Or how can I get the `tag` and `storage` myself? https://github.com/dlang/phobos/blob/a3f22129dd2a134338ca02b79ff0de242d7f016e/std/sumtype.d#L310 If I add this line to the above func `isF`: ``` writeln(t.tag); ``` it won't compile:

is there a way to use sumtype in `switch/case` (with multiple statements)? or how can I get the `tag` and `storage`?

2023-10-07 Thread mw via Digitalmars-d-learn
https://dlang.org/library/std/sumtype.html seems right now the `match!(...)` template only generate a delegate, e.g. suppose the following (silly) code: ``` bool isF(Temperature t) { while (true) { t.match!( (Fahrenheit f) {return true;}, (_) {return false;} // I want to

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: how to assign multiple variables at once by unpacking array?

2023-10-07 Thread ryuukk_ via Digitalmars-d-learn
On Saturday, 7 October 2023 at 17:23:40 UTC, ryuukk_ wrote: On Saturday, 7 October 2023 at 07:31:45 UTC, mw wrote: https://stackoverflow.com/questions/47046850/is-there-any-way-to-assign-multiple-variable-at-once-with-dlang How to do this Python code in D: ``` s = "1 2 3" A,B,C = map(int,

Re: how to assign multiple variables at once by unpacking array?

2023-10-07 Thread ryuukk_ via Digitalmars-d-learn
On Saturday, 7 October 2023 at 07:31:45 UTC, mw wrote: https://stackoverflow.com/questions/47046850/is-there-any-way-to-assign-multiple-variable-at-once-with-dlang How to do this Python code in D: ``` s = "1 2 3" A,B,C = map(int, s.split(" ")) A,B,C (1, 2, 3) ``` Is there a better way

Re: array setting : Whats going in here?

2023-10-07 Thread claptrap via Digitalmars-d-learn
On Saturday, 7 October 2023 at 00:49:39 UTC, H. S. Teoh wrote: On Sat, Oct 07, 2023 at 12:00:48AM +, claptrap via Digitalmars-d-learn wrote: When you write `foo[]` you're taking a slice of the array, and in that case if the lengths of both sides of the assignment don't match, you'll

Re: how to assign multiple variables at once by unpacking array?

2023-10-07 Thread Sergey via Digitalmars-d-learn
On Saturday, 7 October 2023 at 16:12:47 UTC, mw wrote: Interesting: in terms of easy of coding, clarity and future maintenance, which one is superior? There is no superior languages. They can successfully co-exist and play in different areas. The one liner in Python, or your "solution" with

Re: how to assign multiple variables at once by unpacking array?

2023-10-07 Thread mw via Digitalmars-d-learn
Interesting: in terms of easy of coding, clarity and future maintenance, which one is superior? The one liner in Python, or your "solution" with dozen lines of code? BTW, is that a solution at all? Did it achieved what the original goal asked in the OP question? So, who should learn from

Re: how to assign multiple variables at once by unpacking array?

2023-10-07 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 7 October 2023 at 07:31:45 UTC, mw wrote: https://stackoverflow.com/questions/47046850/is-there-any-way-to-assign-multiple-variable-at-once-with-dlang How to do this Python code in D: ``` s = "1 2 3" A,B,C = map(int, s.split(" ")) A,B,C (1, 2, 3) ``` Is there a better way

Re: how to assign multiple variables at once by unpacking array?

2023-10-07 Thread bachmeier via Digitalmars-d-learn
On Saturday, 7 October 2023 at 07:31:45 UTC, mw wrote: https://stackoverflow.com/questions/47046850/is-there-any-way-to-assign-multiple-variable-at-once-with-dlang How to do this Python code in D: ``` s = "1 2 3" A,B,C = map(int, s.split(" ")) A,B,C (1, 2, 3) ``` Is there a better way