Range Construction Pattern

"Nordlöw" per.nordlow at gmail.com
Sat Feb 22 05:18:31 PST 2014


On Saturday, 22 February 2014 at 12:40:42 UTC, Tobias Pankrath 
wrote:
> On Saturday, 22 February 2014 at 12:29:11 UTC, Nordlöw wrote:
>> Assumed I have the following code
>>
>>    SysTime[] times;
>>    const n = 3;
>>    foreach (i; 0..n) times ~= Clock.currTime;
>>
>> is there a simpler, perhaps functional, higher order pattern 
>> with which to achieve the same goal?
>
> What's Clock.currTime exactly, a function?
> --
> times = iota(3).map!(x => Clock.currTime).array;
> --

Great!

See also: 
https://stackoverflow.com/questions/21954381/range-construction-pattern/21954416?noredirect=1#21954416


More information about the Digitalmars-d-learn mailing list