Chris Cain:

https://dl.dropboxusercontent.com/u/2206555/uniformUpgrade.pdf


From page 6:

size_t[] counts = new size_t[](top);
foreach(i; 0 .. 500_000_000)
    counts[uniform(0, top)] += 1;


Modern D allows you to write better code:

size_t[N] counts;
foreach (immutable _; 0 .. 500_000_000)
    counts[uniform(0, $)]++;

Bye,
bearophile

Reply via email to