Range of random numbers

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Mon Apr 23 10:46:35 PDT 2012


On 23/04/12 18:56, bearophile wrote:
> jerro:
>
>> return repeat(0).map!(_ =>  uniform(lower, upper))();
>>
>> repeat(0) returns the same sequence as cycle([0]) and is as fast
>> as it gets, since popFront does nothing and empty is an enum.
>
> Good idea.

Yes, this works nicely.  Thanks very much!


More information about the Digitalmars-d-learn mailing list