Re: dlang.org/Learn "hello_world".sort.chain ...
On Tuesday, 26 December 2023 at 10:53:10 UTC, Tony wrote: I just typed in the program that is on the first page of Learn. It has this line: sort(chain(arr1, arr2, arr3)); I assigned that to a variable: arr4 = sort(chain(arr1, arr2, arr3)); then printed it out writefln("%s",arr4); // works and then tried to print out the type of arr4: writefln("%s",typeof(arr4)); and got this error: // HelloWorld.d:25:19: error: cannot pass type SortedRange!(Result, "a < b") as a function argument What exactly is that type? Or maybe, what would it take to understand what that type is? The error message suggests that `SortedRange!(Result, "a < b")` is the type returned by the `sort` function. For additional insights and assistance, you can explore resources like online dissertation help literature review https://literaturereviewwritingservice.com/ This type represents a sorted range of elements, possibly of type `Result`, sorted based on the comparison predicate `"a < b"`. To understand it better, you may need to inspect its definition or consider alternative methods for printing its type.
Re: dlang.org/Learn "hello_world".sort.chain ...
On Tuesday, 26 December 2023 at 13:58:54 UTC, tony wrote: On Tuesday, 26 December 2023 at 11:19:29 UTC, Sergey wrote: Use typeid, instead of typeof Thanks! Got quite a type but I will worry about that later: std.range.SortedRange!(Result, "a < b").SortedRange Yes, because sort is returning special type, compatible with Ranges interface. You can add 'sort(...).array' and the type will become 'int[]' (or which types arrays were before). Ranges are specific things for D (one of the core feature of the lang and std), which can evaluated lazily. You can check some description how they are working in the documentation https://dlang.org/phobos/std_range.html
Re: dlang.org/Learn "hello_world".sort.chain ...
On Tuesday, 26 December 2023 at 11:19:29 UTC, Sergey wrote: Use typeid, instead of typeof Thanks! Got quite a type but I will worry about that later: std.range.SortedRange!(Result, "a < b").SortedRange
Re: dlang.org/Learn "hello_world".sort.chain ...
On Tuesday, 26 December 2023 at 10:53:10 UTC, Tony wrote: I just typed in the program that is on the first page of Learn. It has this line: sort(chain(arr1, arr2, arr3)); I assigned that to a variable: arr4 = sort(chain(arr1, arr2, arr3)); then printed it out writefln("%s",arr4); // works and then tried to print out the type of arr4: writefln("%s",typeof(arr4)); and got this error: // HelloWorld.d:25:19: error: cannot pass type SortedRange!(Result, "a < b") as a function argument What exactly is that type? Or maybe, what would it take to understand what that type is? Use typeid, instead of typeof