Generate array of random values

Pelle pelle.mansson at gmail.com
Tue Aug 2 00:38:12 PDT 2011


On Mon, 01 Aug 2011 21:43:13 +0200, Andrej Mitrovic  
<andrej.mitrovich at gmail.com> wrote:

> Actually I don't really need *uniform* distribution, it's just that
> when porting C code to D I didn't find any obvious random()/rnd()
> functions, and uniform seemed to be the closest thing without having
> to mess around with a bunch of randomization parameters which I don't
> care about.
>
> I don't see how we can claim D to be an elegant language with this mess:
> array(map!"a % 1024"(take(rndGen(), 1024)))
>
> That's just damn *horrible*.

If we ever get UFCS that'd be rndGen().take(1024).map!"a % 1024"().array()

Which is a lot better :--)

Without UFCS, well, how would you want it to look? How does it look in  
other languages?


More information about the Digitalmars-d-learn mailing list