Re: Strange behavior of iota

2022-02-16 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 16 February 2022 at 19:35:00 UTC, jmh530 wrote: [snip] Step 1: In the integral overloads, use allSatisfy!(isSigned, B, E) || allSatisfy!(isUnsigned, T, U) for the current behavior Step 2: When !(allSatisfy!(isSigned, B, E) || allSatisfy!(isUnsigned, T, U)), then convert to

Re: Strange behavior of iota

2022-02-16 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 16 February 2022 at 15:55:55 UTC, bachmeier wrote: On Wednesday, 16 February 2022 at 15:21:11 UTC, jmh530 wrote: On Tuesday, 15 February 2022 at 22:24:53 UTC, bachmeier wrote: [snip] After looking at the documentation and seeing CommonType!(int, uint) is uint, I have to say

Re: Strange behavior of iota

2022-02-16 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 16 February 2022 at 15:21:11 UTC, jmh530 wrote: On Tuesday, 15 February 2022 at 22:24:53 UTC, bachmeier wrote: [snip] After looking at the documentation and seeing CommonType!(int, uint) is uint, I have to say that iota's behavior doesn't make much sense. What do you propose

Re: Strange behavior of iota

2022-02-16 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 15 February 2022 at 22:24:53 UTC, bachmeier wrote: [snip] After looking at the documentation and seeing CommonType!(int, uint) is uint, I have to say that iota's behavior doesn't make much sense. What do you propose as an alternative? What about the narrowest type that fits

Re: Strange behavior of iota

2022-02-16 Thread bachmeier via Digitalmars-d-learn
On Wednesday, 16 February 2022 at 02:51:32 UTC, Era Scarecrow wrote: On Tuesday, 15 February 2022 at 22:24:53 UTC, bachmeier wrote: On Tuesday, 15 February 2022 at 22:02:13 UTC, Adam D Ruppe wrote: for(a = v.length; a > cast(size_t) -1, a += -1) After looking at the documentation and seeing

Re: Strange behavior of iota

2022-02-15 Thread Era Scarecrow via Digitalmars-d-learn
On Tuesday, 15 February 2022 at 22:24:53 UTC, bachmeier wrote: On Tuesday, 15 February 2022 at 22:02:13 UTC, Adam D Ruppe wrote: for(a = v.length; a > cast(size_t) -1, a += -1) After looking at the documentation and seeing CommonType!(int, uint) is uint, I have to say that iota's behavior

Re: Strange behavior of iota

2022-02-15 Thread bachmeier via Digitalmars-d-learn
On Tuesday, 15 February 2022 at 22:02:13 UTC, Adam D Ruppe wrote: On Tuesday, 15 February 2022 at 21:48:29 UTC, bachmeier wrote: writeln(iota(v.length,-1,-1)); This would be like for(a = v.length; a > cast(size_t) -1, a += -1) That (cast(size_t) -1) is the same as thing.max, meaning a

Re: Strange behavior of iota

2022-02-15 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 15 February 2022 at 21:48:29 UTC, bachmeier wrote: writeln(iota(v.length,-1,-1)); This would be like for(a = v.length; a > cast(size_t) -1, a += -1) That (cast(size_t) -1) is the same as thing.max, meaning a will never be greater than it. Why does the first argument to

Strange behavior of iota

2022-02-15 Thread bachmeier via Digitalmars-d-learn
This code ``` import std.conv, std.range, std.stdio; void main() { auto v = [1, 2, 3, 4, 5]; writeln(iota(v.length,-1,-1)); writeln(iota(v.length,-1.to!long,-1)); writeln(iota(v.length.to!int,-1,-1)); writeln(iota(v.length.to!uint,-1,-1));