| Thread overview | |||||
|---|---|---|---|---|---|
|
April 05, 2015 Mixin and map | ||||
|---|---|---|---|---|
| ||||
Hi,
Can you please tell how to make map worked correctly. I want to program published [2, 3, 4, 5, 6].
-----
import std.stdio;
import std.algorithm;
string print(string s)
{
return `writeln(` ~ s ~ `);`;
}
void main()
{
auto arr = [1, 2, 3, 4, 5];
mixin(print(`arr.map!(t => t++)`)); // prints [1, 2, 3, 4, 5]
}
-----
http://ideone.com/yEmzA4
| ||||
April 05, 2015 Re: Mixin and map | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Dennis Ritchie | On Sunday, 5 April 2015 at 21:23:14 UTC, Dennis Ritchie wrote: > Hi, > Can you please tell how to make map worked correctly. I want to program published [2, 3, 4, 5, 6]. > > ----- > import std.stdio; > import std.algorithm; > > string print(string s) > { > return `writeln(` ~ s ~ `);`; > } > > void main() > { > auto arr = [1, 2, 3, 4, 5]; > > mixin(print(`arr.map!(t => t++)`)); // prints [1, 2, 3, 4, 5] > } > ----- > http://ideone.com/yEmzA4 Post incrementing t is not storing the increments value. http://ideone.com/1gGnvP | |||
April 05, 2015 Re: Mixin and map | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Gary Willoughby | On Sunday, 5 April 2015 at 21:28:27 UTC, Gary Willoughby wrote:
> Post incrementing t is not storing the increments value.
>
> http://ideone.com/1gGnvP
Thanks.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply