Re: Fix template parameter

2022-08-09 Thread Dom Disc via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 22:58:16 UTC, Paul Backus wrote: On Tuesday, 9 August 2022 at 22:36:23 UTC, Dom Disc wrote: On Tuesday, 9 August 2022 at 22:32:23 UTC, Dom Disc wrote: On Tuesday, 9 August 2022 at 21:16:22 UTC, Paul Backus wrote: Yes, this syntax allows anything that implicitly conv

Re: "min" and "max"

2022-08-09 Thread pascal111 via Digitalmars-d-learn
On Wednesday, 10 August 2022 at 00:32:02 UTC, Ali Çehreli wrote: On 8/9/22 17:03, pascal111 wrote: > as a beginner how can I guess what "NaNs" > means or if it refers to ranges?! You can use the index: ;) http://ddili.org/ders/d.en/ix.html There are a couple of entries for 'nan' there. Ali

Re: "min" and "max"

2022-08-09 Thread Ali Çehreli via Digitalmars-d-learn
On 8/9/22 17:03, pascal111 wrote: > They said " If at least one of the arguments is NaN, the result is an > unspecified value. That's called "unorderedness": http://ddili.org/ders/d.en/floating_point.html#ix_floating_point.unordered > as a beginner how can I guess what "NaNs" > means or if it

Re: Cast converts AA to rvalue?

2022-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/22 7:02 PM, Johan wrote: Testcase: ``` shared int[int] aa; void main () {     cast()aa[1] = 1; } ``` Up to dlang 2.097, this program runs and works fine. Since dlang 2.098, the program errors with: `core.exception.RangeError@/app/example.d(3): Range violation` I think the 2.098+ behavio

Re: "min" and "max"

2022-08-09 Thread jfondren via Digitalmars-d-learn
On Wednesday, 10 August 2022 at 00:03:37 UTC, pascal111 wrote: On Tuesday, 9 August 2022 at 23:56:53 UTC, Paul Backus wrote: On Tuesday, 9 August 2022 at 23:35:23 UTC, pascal111 wrote: "min" and "max" in "std.algorithm" can be used with single values to pick up the min and max values, but it di

Re: "min" and "max"

2022-08-09 Thread pascal111 via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 23:56:53 UTC, Paul Backus wrote: On Tuesday, 9 August 2022 at 23:35:23 UTC, pascal111 wrote: "min" and "max" in "std.algorithm" can be used with single values to pick up the min and max values, but it didn't mention how they can be used with ranges in the documentat

Re: "min" and "max"

2022-08-09 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 23:35:23 UTC, pascal111 wrote: "min" and "max" in "std.algorithm" can be used with single values to pick up the min and max values, but it didn't mention how they can be used with ranges in the documentation: https://dlang.org/phobos/std_algorithm_comparison.html#.

"min" and "max"

2022-08-09 Thread pascal111 via Digitalmars-d-learn
"min" and "max" in "std.algorithm" can be used with single values to pick up the min and max values, but it didn't mention how they can be used with ranges in the documentation: https://dlang.org/phobos/std_algorithm_comparison.html#.min

Cast converts AA to rvalue?

2022-08-09 Thread Johan via Digitalmars-d-learn
Testcase: ``` shared int[int] aa; void main () { cast()aa[1] = 1; } ``` Up to dlang 2.097, this program runs and works fine. Since dlang 2.098, the program errors with: `core.exception.RangeError@/app/example.d(3): Range violation` I think the 2.098+ behavior is correct, but I cannot find a

Re: Fix template parameter

2022-08-09 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 22:36:23 UTC, Dom Disc wrote: On Tuesday, 9 August 2022 at 22:32:23 UTC, Dom Disc wrote: On Tuesday, 9 August 2022 at 21:16:22 UTC, Paul Backus wrote: Yes, this syntax allows anything that implicitly converts to `BigInt`; Oh, or do you mean I will get two differen

Re: Fix template parameter

2022-08-09 Thread Dom Disc via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 22:32:23 UTC, Dom Disc wrote: On Tuesday, 9 August 2022 at 21:16:22 UTC, Paul Backus wrote: Yes, this syntax allows anything that implicitly converts to `BigInt`; Oh, or do you mean I will get two different instances of the template, if I call it with two differen

Re: Fix template parameter

2022-08-09 Thread Dom Disc via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 21:16:22 UTC, Paul Backus wrote: Yes, this syntax allows anything that implicitly converts to `BigInt`; for example: ```d import std.bigint; void fun(T : BigInt)(T t) { pragma(msg, "Instantiated with T = `" ~ T.stringof ~ "`"); } struct S { BigInt n; a

Re: A look inside "filter" function defintion

2022-08-09 Thread Meta via Digitalmars-d-learn
On Monday, 1 August 2022 at 23:35:13 UTC, pascal111 wrote: This is the definition of "filter" function, and I think it called itself within its definition. I'm guessing how it works? '''D template filter(alias predicate) if (is(typeof(unaryFun!predicate))) { /** Params: range =

Re: Fix template parameter

2022-08-09 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 21:08:52 UTC, Meta wrote: (it may also include anything that is a subtype of BigInt... I've received different answers on what exactly `(T: SomeType)` means in this context). Yes, this syntax allows anything that implicitly converts to `BigInt`; for example: ```

Re: Fix template parameter

2022-08-09 Thread Meta via Digitalmars-d-learn
On Monday, 8 August 2022 at 12:02:02 UTC, Dom Disc wrote: Hello. I found in the documentation functions declared like this: ```D pure @nogc @safe BigInt opAssign(T : BigInt)(T x); ``` This is a template function, even if T is constrained to always be BigInt (it may also include anything that

Re: Fix template parameter

2022-08-09 Thread pascal111 via Digitalmars-d-learn
On Monday, 8 August 2022 at 14:48:27 UTC, Dom Disc wrote: On Monday, 8 August 2022 at 12:46:48 UTC, bauss wrote: On Monday, 8 August 2022 at 12:02:02 UTC, Dom Disc wrote: ```D pure @nogc @safe BigInt opAssign(T : BigInt)(T x); ``` This will only be included in the object file if used. ```D

Re: A look inside "filter" function defintion

2022-08-09 Thread Patrick Schluter via Digitalmars-d-learn
On Tuesday, 2 August 2022 at 12:39:41 UTC, pascal111 wrote: On Tuesday, 2 August 2022 at 04:06:30 UTC, frame wrote: On Monday, 1 August 2022 at 23:35:13 UTC, pascal111 wrote: This is the definition of "filter" function, and I think it called itself within its definition. I'm guessing how it wo

Re: Copying and array into another

2022-08-09 Thread pascal111 via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 18:41:52 UTC, Paul Backus wrote: On Tuesday, 9 August 2022 at 18:33:04 UTC, pascal111 wrote: I tried to copy an array into another without affecting in the original array when I try to change the value of any element of the new array, but I failed except with this w

Re: Copying and array into another

2022-08-09 Thread pascal111 via Digitalmars-d-learn
Edit "Copying an array into another" in the title.

Re: Copying and array into another

2022-08-09 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 18:33:04 UTC, pascal111 wrote: I tried to copy an array into another without affecting in the original array when I try to change the value of any element of the new array, but I failed except with this way in the next code: '''D int[] x=[1,2,3]; int[] y=x.fil

Copying and array into another

2022-08-09 Thread pascal111 via Digitalmars-d-learn
I tried to copy an array into another without affecting in the original array when I try to change the value of any element of the new array, but I failed except with this way in the next code: '''D int[] x=[1,2,3]; int[] y=x.filter!("a==a").array; y[1]=800; x.writeln; y.write

Re: A look inside "filter" function defintion

2022-08-09 Thread pascal111 via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 18:23:04 UTC, Ali Çehreli wrote: On 8/2/22 05:39, pascal111 wrote: > I'm still stuck. Do you have a > down-to-earth example for beginners to understand this concept? I will refer to my explanation because down-to-earth has always been my goal. I hope i succeeded:

Re: Breaking ";" rule with lambda functions

2022-08-09 Thread pascal111 via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 18:10:25 UTC, Ali Çehreli wrote: On 8/2/22 09:40, pascal111 wrote: > [...] in C++, so > [...] Lambdas are a common feature of many programming languages. C++ got lambdas in their C++11 release, many years after D and many other languages had them. (It is not commo

Re: A look inside "filter" function defintion

2022-08-09 Thread Ali Çehreli via Digitalmars-d-learn
On 8/2/22 05:39, pascal111 wrote: > I'm still stuck. Do you have a > down-to-earth example for beginners to understand this concept? I will refer to my explanation because down-to-earth has always been my goal. I hope i succeeded: http://ddili.org/ders/d.en/templates_more.html#ix_templates_m

Re: Breaking ";" rule with lambda functions

2022-08-09 Thread Ali Çehreli via Digitalmars-d-learn
On 8/2/22 09:40, pascal111 wrote: > Maybe I'd wrong beliefs about lambda function. It's already in C++, so > it's a traditional feature Lambdas are a common feature of many programming languages. C++ got lambdas in their C++11 release, many years after D and many other languages had them. (It

Re: char* pointers between C and D

2022-08-09 Thread Ali Çehreli via Digitalmars-d-learn
On 7/25/22 06:51, ryuukk_ wrote: > On Monday, 25 July 2022 at 11:14:56 UTC, pascal111 wrote: >> const(char)[] ch1 = "Hello World!"; >> char[] ch2="Hello World!".dup; [...] > `ch1`is a string literal, just like in C, it is null terminated To be pedantic, ch1 is not the string li

Re: OK to do bit-packing with GC pointers?

2022-08-09 Thread Ali Çehreli via Digitalmars-d-learn
On 7/22/22 09:50, Ben Jones wrote: > any problems with the GC? The slides don't seem to mention the GC but Amaury Séchet had given a presentation on bit packing: http://dconf.org/2016/talks/sechet.html Ali

Re: dirEntries() does not do source files *.d

2022-08-09 Thread rikki cattermole via Digitalmars-d-learn
Its working for me. lpha@DESKTOP-RB97SA4 [/cygdrive/p/ProjectSidero/basic_memory/source/sidero/base/text/unicode$ rdmd --eval=$'import std; writeln(dirEntries(`.`, `*.d`, SpanMode.shallow));' [".\\casefold.d", ".\\casing.d", ".\\comparison.d", ".\\composing.d", ".\\defs.d", ".\\norm

Re: dirEntries() does not do source files *.d

2022-08-09 Thread Energo Koder via Digitalmars-d-learn
On Tuesday, 9 August 2022 at 12:09:18 UTC, Energo Koder wrote: Was: dirEntries() does not do source files *.d . Should be: dirEntries() does not list source files *.d

dirEntries() does not do source files *.d

2022-08-09 Thread Energo Koder via Digitalmars-d-learn
Dzień dobry! dirEntries() does not do source files *.d . I notice this when i test my app. Telme: Os this expected behavior? Miłego dnia! Energo Koder