Generate array of random values
Dmitry Olshansky
dmitry.olsh at gmail.com
Mon Aug 1 14:44:32 PDT 2011
On 01.08.2011 23:43, Andrej Mitrovic 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*.
Dunno maybe it's only me, but some years ago when I used C++98 & STL
extensively I would find this line a very simple and clean solution. Now
time is changing and so on...
A thought - would amap as a shorthand for array(map... float your boat?
One pair of parens off.
--
Dmitry Olshansky
More information about the Digitalmars-d-learn
mailing list