Append to 'map' result
H. S. Teoh via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jul 4 16:26:28 PDT 2017
On Tue, Jul 04, 2017 at 11:27:25PM +0000, Jean-Louis Leroy via Digitalmars-d-learn 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.
[...]
Try:
auto z = chain(y, only(99));
T
--
I don't trust computers, I've spent too long programming to think that they can get anything right. -- James Miller
More information about the Digitalmars-d-learn
mailing list