Re: Why does choose not work here

2019-08-02 Thread berni via Digitalmars-d-learn
On Thursday, 1 August 2019 at 21:26:10 UTC, Matt wrote: Anyone have any other thoughts? I tried to simplify your example a little bit: import std.stdio; import std.range; import std.algorithm; auto myFilter(R1, R2)(R1 a, R2 b) { return a.filter!(c => c==b.front); } struct A { int[]

Re: Why does choose not work here

2019-08-01 Thread Matt via Digitalmars-d-learn
On Thursday, 1 August 2019 at 21:12:51 UTC, ag0aep6g wrote: `choose`'s parameters aren't lazy. So the second argument is evaluated even when `previous is null`. That means `intervalRange` is called on a null `previous`. And that fails, of course, because `intervalRange` can't access `starts`

Re: Why does choose not work here

2019-08-01 Thread ag0aep6g via Digitalmars-d-learn
On 01.08.19 22:23, Matt wrote: Version 4 does not work when PairedA.previous is null. I'd love to understand why. [...] auto myFilter(R1, R2)(R1 a, R2 b) { import std.algorithm : filter, canFind; return a.filter!(c => b.canFind(c)); } struct A { uint[] starts, stops;

Why does choose not work here

2019-08-01 Thread Matt via Digitalmars-d-learn
I'm having some trouble with a "Program exited with code -1073741819" error in some code I'm writing and I would appreciate any help/insight. The problem stems from some incompatibility between the Phobos function "choose" and the template function "myFilter" which returns a range. The code