What is "FilterResult" type?
Bahman Movaqar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Sep 9 04:30:24 PDT 2015
On Wednesday, 9 September 2015 at 08:29:20 UTC, cym13 wrote:
> You are using reduce in a weird way here...
Oh? Perhaps it was all because of the lame example I used :-)
The real problem I was trying to solve, source of which I just
pushed[1], was the `select` method on line 130. Is this
idiomatic or still weird?
> The way I would have written it is:
>
> auto result = foobars.filter!(fb => nums.all!(n => (fb.x *
> fb.y) > n))
> .filter!(fb => nums.all!(n => fb.x < n &&
> fb.y < n));
For the lame example I gave, something similar occurred to me at
first; but then I thought 4 `filter`s (assuming `all` is simply a
`filter`) might be non-idiomatic as it might incur some
performance penalty.
> Here you don't have any weird and completely unreadable reduce
> construct and don't have to realize the lazy check as
> std.algorithm.searching.all is lazy too.
True. But is pumping the output of `filter` as the seed into
`reduce` really considered weird usage!?
[1]
https://github.com/bahmanm/d-etudes/blob/master/source/e002/models.d
More information about the Digitalmars-d-learn
mailing list