i wrote a histogram algorithm
i tried to write it the shortest and most "D" way possible ...
please tell me if you see any simpler way of doing it
is there a simpler way of getting the minimum of a range? (by
intuition i tried range.min)
auto numbers = iota(0,10000).map!(_ => uniform(0.0,1.0)).array;
auto nmin = numbers.reduce!((a,b) => min(a,b));
auto nmax = numbers.reduce!((a,b) => max(a,b)) + double.epsilon;
int bins = 100;
auto bin = iota!float(0, bins).map!(a =>
tuple((nmax-nmin)/bins*a+nmin, (nmax-nmin)/bins*(a+1)+nmin));
auto bincount = bin.map!(a => numbers.map!(b => b >= a[0] && b <
a[1] ? 1 : 0).sum);
bincount.writeln;