Alternative to std.range.choose

2020-07-21 Thread James Gray via Digitalmars-d-learn
Is there a better way to achieve behaviour similar to rangeFuncIf below? f gives a contrived example of when one might want this. g is how one might try and achieve the same with std.range.choose. import std.stdio; import std.range : only, chain, join, choose; import std.algorithm : map; auto

Re: Alternative to std.range.choose

2020-07-21 Thread WebFreak001 via Digitalmars-d-learn
On Wednesday, 22 July 2020 at 04:33:20 UTC, James Gray wrote: Is there a better way to achieve behaviour similar to rangeFuncIf below? f gives a contrived example of when one might want this. g is how one might try and achieve the same with std.range.choose. import std.stdio; import std.range

Re: Alternative to std.range.choose

2020-07-22 Thread James Gray via Digitalmars-d-learn
On Wednesday, 22 July 2020 at 06:16:44 UTC, WebFreak001 wrote: On Wednesday, 22 July 2020 at 04:33:20 UTC, James Gray wrote: [...] it seems `choose` evaluates both arguments instead of using lazy evaluation. IMO this is a broken API to me but it has been like this for longer so this would be

Re: Alternative to std.range.choose

2020-07-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/22/20 12:33 AM, James Gray wrote: Is there a better way to achieve behaviour similar to rangeFuncIf below? f gives a contrived example of when one might want this. g is how one might try and achieve the same with std.range.choose. import std.stdio; import std.range : only, chain, join, choo