On Sunday, 26 August 2018 at 06:08:39 UTC, vit wrote:
const x = iota(0, 10)
.map!((x, i) => x*i)(a) ///map!((x) => x*a)
.map!((x, i) => x*i)(b) ///map!((x) => x*b)
.filter!((x, i) => x%i)(c)///filter!((x) => x%c)
.any!(x => x % c);
I think it's easier to
On Friday, 24 August 2018 at 22:51:40 UTC, Paul Backus wrote:
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
On Friday, 24 August 2018 at 15:18:13 UTC, Peter Alexander wrote:
Consider this code, which is used as an example only:
auto scaleAll(int[] xs, int m) {
return xs.map!(x => m * x);
}
As m is captured, the delegate for map will rightly allocate
the closure in the GC heap.
In C++, you would
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
On 8/24/18 11:18 AM, Peter Alexander wrote:
Consider this code, which is used as an example only:
auto scaleAll(int[] xs, int m) {
return xs.map!(x => m * x);
}
As m is captured, the delegate for map will rightly allocate the closure
in the GC heap.
In C++, you would write the lambda to
Consider this code, which is used as an example only:
auto scaleAll(int[] xs, int m) {
return xs.map!(x => m * x);
}
As m is captured, the delegate for map will rightly allocate the
closure in the GC heap.
In C++, you would write the lambda to capture m by value, but
this is not a