March 2014 update

This commit is contained in:
Ingy döt Net 2014-04-02 16:56:35 +00:00
parent 09687c4926
commit a25938f123
1846 changed files with 21876 additions and 5203 deletions

View file

@ -1,7 +1,7 @@
import std.stdio, std.random, std.algorithm;
double random01(ref Xorshift rng) {
immutable r = rng.front / cast(double)rng.max;
immutable r = rng.front / double(rng.max);
rng.popFront;
return r;
}
@ -14,7 +14,7 @@ struct SOfN(size_t n) {
i++;
if (i <= n)
sample[i - 1] = item;
else if (rng.random01 < (cast(double)n / i))
else if (rng.random01 < (double(n) / i))
sample[uniform(0, n, rng)] = item;
return sample[0 .. min(i, $)];
}