Patterns to avoid GC with capturing closures?
Paul Backus
snarwin at gmail.com
Fri Aug 24 22:51:40 UTC 2018
On Friday, 24 August 2018 at 15:18:13 UTC, Peter Alexander wrote:
> I can write scaleAll like this:
>
> auto scaleAll(int[] xs, int m) @nogc {
> return repeat(m).zip(xs).map!(mx => mx[0] * mx[1]);
> }
>
> So that repeat(m) stores m, but it is quite hacky to work like
> this.
Here's a spoonful of sugar to help that go down easier:
https://run.dlang.io/is/8lTmZg
More information about the Digitalmars-d-learn
mailing list