Turn function into infinite range
monarch_dodra via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Sep 29 14:20:22 PDT 2014
On Monday, 29 September 2014 at 21:16:27 UTC, Daniel Kozák via
Digitalmars-d-learn wrote:
> V Mon, 29 Sep 2014 19:02:36 +0200
> Martin Nowak via Digitalmars-d-learn
> <digitalmars-d-learn at puremagic.com> napsáno:
>
>> Does anyone know a construct to turn a lambda into an infinite
>> range.
>>
>> import std.random;
>>
>> unittest
>> {
>> Random gen;
>> foreach(v; xxx!(() => uniform(0, 100, gen)).take(10))
>> writeln(v);
>> }
>>
>> I though I've seen this around somewhere but can no longer
>> find it.
>
> http://dlang.org/phobos/std_range.html#.Repeat ?
That just repeats the value, but doesn't re-evaluate the value on
every call to front/popFront.
More information about the Digitalmars-d-learn
mailing list