Append to 'map' result
Nicholas Wilson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jul 4 16:50:57 PDT 2017
On Tuesday, 4 July 2017 at 23:27:25 UTC, Jean-Louis Leroy wrote:
> I want to create a range that consists of the result of a map()
> followed by a value, e.g.:
>
> int[] x = [ 1, 2, 3];
> auto y = map!(x => x * x)(x);
> auto z = y ~ 99; // how???
>
> I have tried several variations: convert 99 to a dynamic array,
> to a range, convert range to dynamic array (couldn't even
> figure that one); to no avail.
>
> Help please...
using
auto y = x.map!(x => x * x).array;
will work.
More information about the Digitalmars-d-learn
mailing list