histogram [last thread contd]
bearophile via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jan 22 13:19:33 PST 2015
ddos:
> auto numbers = iota(0,10000).map!(_ => uniform(0.0,1.0)).array;
Better:
const numbers = 10_000.iota.map!(_ => uniform01).array;
> auto nmin = numbers.reduce!((a,b) => min(a,b));
Better:
immutable nMin = numbers.reduce!min;
You can also combine both (untested):
immutable nMinMax = numbers.reduce!(min, max);
> auto nmax = numbers.reduce!((a,b) => max(a,b)) + double.epsilon;
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list