mir: How to change iterator?

Basile B. b2.temp at gmx.com
Thu Apr 16 19:59:57 UTC 2020


On Thursday, 16 April 2020 at 19:56:21 UTC, Basile B. wrote:
> On Tuesday, 14 April 2020 at 20:24:05 UTC, jmh530 wrote:
>> [...]
>
> `approxEqual` cant work with ranges. If you look at the 
> signature there is a use of the constructor syntax, e.g const 
> `T maxRelDiff = T(0x1p-20f)` so when `T` is not a basic FP type 
> that just does not compile (note the error message if you try 
> with .array on both operands)
>
> I'd just use zip(...).each!(...), e.g
>
>     assert(zip(y, [2.5, 2.5].sliced(2)).each!(a => 
> assert(approxEqual(a[0], a[1]))));

And remove the extra assert() BTW... I don't know why this is 
accepted.


More information about the Digitalmars-d-learn mailing list