Map, filter and pure functions
realhet
real_het at hotmail.com
Fri Nov 29 15:30:22 UTC 2019
Hi,
I have an input range.
I use the map! on it to transform using a function.
Finally I use filter! on the transformed data.
When I do a foreach on this, i noticed, that the transform
function is called twice for each element.
If I remove the filter! it does only one transform function call
per element.
Is this because the function is NOT PURE, so Phobos thinks that
the function can give different results for the same input?
If I modify the function to be pure, will the transform function
be called only once?
More information about the Digitalmars-d-learn
mailing list