commit de950b144e0050dfefd73301b14f256d3d562f71
parent 1ae6ddfe9fd94c247c02a167c694b3dbbdd2d0e4
Author: Dominik Schmidt <das1993@hotmail.com>
Date: Sun, 9 Aug 2015 23:02:03 +0200
Remove the randomness-functions.
We do not concern ourselves with such trivialities!1
Diffstat:
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/dfortune.d b/dfortune.d
@@ -4,7 +4,6 @@ import std.conv;
import std.bitmanip;
import std.encoding;
import std.range;
-import std.random;
import std.algorithm;
import core.exception;
@@ -35,9 +34,6 @@ class Fortune : RandomAccessFinite!(Cookie){
return 5*uint.sizeof+char.sizeof;
}
}
- static public auto chooseRandom(T)(T r) if( hasLength!(T) && isRandomAccessRange!(T) ){
- return r[uniform(0,r.length)];
- }
Header header;
string basename;
File table,content;
@@ -242,7 +238,6 @@ struct Fortunes{
fortunes~=f;
end+=f.length-1;
}
- alias chooseRandom=Fortune.chooseRandom;
auto @property strings(){
return map!(a=>a.toString())(this);
}
diff --git a/examples/randomFortune.d b/examples/randomFortune.d
@@ -1,5 +1,6 @@
import dfortune;
import std.stdio;
+import std.random;
int main(string args[]){
Fortunes f;
@@ -8,6 +9,6 @@ int main(string args[]){
return 1;
}
f.add(args[1..$]);
- writeln(f.chooseRandom(f));
+ writeln(f.randomSample(1).front);
return 0;
}