fork(1) download
  1. import std.stdio: writeln;
  2. import std.random: uniform;
  3. import std.range: iota;
  4. import std.algorithm.iteration: map, sum;
  5.  
  6. int d(int x, int y) {
  7. return iota(x).map!(x => uniform(1, y)).sum;
  8. }
  9.  
  10. void main()
  11. {
  12. writeln("2d6 = ", 2.d(6));
  13. }
Success #stdin #stdout 0s 2664KB
stdin
Standard input is empty
stdout
2d6 = 3