Map, filter and pure functions
realhet
real_het at hotmail.com
Fri Nov 29 15:54:13 UTC 2019
On Friday, 29 November 2019 at 15:49:24 UTC, Paul Backus wrote:
> It's actually a much simpler reason: filter calls .front twice
> for each element in its input (once to check if the value
> satisfies the predicate, and then again to return the value if
> it does), and the range returned by map doesn't save the value
> of .front between calls, so it has to re-compute it each time
> by calling the transform function.
This makes it clear.
In my case a cache which can access all the previous elements
would be a too big thing, so I will do the filtering in a later
stage manually. But most importantly, now I know what's going on,
Thank You!
More information about the Digitalmars-d-learn
mailing list