Re: mir: How to change iterator?

2020-04-20 Thread jmh530 via Digitalmars-d-learn
On Monday, 20 April 2020 at 00:27:40 UTC, 9il wrote: [snip] Using two arguments Iterator1, Iterator2 works without allocation /+dub.sdl: dependency "mir-algorithm" version="~>3.7.28" +/ import mir.ndslice; void foo(Iterator1, Iterator2, SliceKind kind) (Slice!(Iterator1, 1, kind) x,

Re: mir: How to change iterator?

2020-04-19 Thread 9il via Digitalmars-d-learn
On Sunday, 19 April 2020 at 22:07:30 UTC, jmh530 wrote: On Thursday, 16 April 2020 at 20:59:36 UTC, jmh530 wrote: [snip] /+dub.sdl: dependency "mir-algorithm" version="~>3.7.28" +/ import mir.ndslice; void foo(Iterator, SliceKind kind)(Slice!(Iterator, 1, kind) x, Slice!(Iterator, 1, kind)

Re: mir: How to change iterator?

2020-04-19 Thread jmh530 via Digitalmars-d-learn
On Thursday, 16 April 2020 at 20:59:36 UTC, jmh530 wrote: [snip] /+dub.sdl: dependency "mir-algorithm" version="~>3.7.28" +/ import mir.ndslice; void foo(Iterator, SliceKind kind)(Slice!(Iterator, 1, kind) x, Slice!(Iterator, 1, kind) y) { import std.stdio : writeln;

Re: mir: How to change iterator?

2020-04-18 Thread 9il via Digitalmars-d-learn
On Sunday, 19 April 2020 at 02:56:30 UTC, 9il wrote: On Friday, 17 April 2020 at 08:40:36 UTC, WebFreak001 wrote: On Tuesday, 14 April 2020 at 20:24:05 UTC, jmh530 wrote: [...] Use std.algorithm:equal for range compare with approxEqual for your comparator: assert(equal!approxEqual(y,

Re: mir: How to change iterator?

2020-04-18 Thread 9il via Digitalmars-d-learn
On Friday, 17 April 2020 at 08:40:36 UTC, WebFreak001 wrote: On Tuesday, 14 April 2020 at 20:24:05 UTC, jmh530 wrote: [...] Use std.algorithm:equal for range compare with approxEqual for your comparator: assert(equal!approxEqual(y, [2.5, 2.5].sliced(2))); or mir.algorithm.iteration: each

Re: mir: How to change iterator?

2020-04-17 Thread WebFreak001 via Digitalmars-d-learn
On Friday, 17 April 2020 at 08:40:36 UTC, WebFreak001 wrote: On Tuesday, 14 April 2020 at 20:24:05 UTC, jmh530 wrote: [...] Use std.algorithm:equal for range compare with approxEqual for your comparator: assert(equal!approxEqual(y, [2.5, 2.5].sliced(2))); simplified:

Re: mir: How to change iterator?

2020-04-17 Thread WebFreak001 via Digitalmars-d-learn
On Tuesday, 14 April 2020 at 20:24:05 UTC, jmh530 wrote: In the code below, I multiply some slice by 5 and then check whether it equals another slice. This fails for mir's approxEqual because the two are not the same types (yes, I know that isClose in std.math works). I was trying to convert

Re: mir: How to change iterator?

2020-04-16 Thread jmh530 via Digitalmars-d-learn
On Thursday, 16 April 2020 at 19:59:57 UTC, Basile B. wrote: [snip] And remove the extra assert() BTW... I don't know why this is accepted. Thanks, I hadn't realized about approxEqual. I think that resolves my near-term issue, I would need to play around with things a little more to be

Re: mir: How to change iterator?

2020-04-16 Thread Basile B. via Digitalmars-d-learn
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

Re: mir: How to change iterator?

2020-04-16 Thread Basile B. via Digitalmars-d-learn
On Tuesday, 14 April 2020 at 20:24:05 UTC, jmh530 wrote: In the code below, I multiply some slice by 5 and then check whether it equals another slice. This fails for mir's approxEqual because the two are not the same types (yes, I know that isClose in std.math works). I was trying to convert