On Saturday, 9 December 2017 at 04:31:33 UTC, SimonN wrote:

Yes, this works, and your algorithm would even accept arbitary random-access ranges, not merely arrays.


Would be nice if I could do it all as a 'one liner':

// --------
int[] draw8Numbers()
{
    import std.algorithm.sorting : sort;
    import std.random : randomShuffle;
    import std.meta : aliasSeqOf;
    import std.range : iota;
    import std.range : take;
    import std.array : array;

// return a sorted array of 8 random numbers, between 1..45 inclusive. return sort(randomShuffle([ aliasSeqOf!(iota(1,46)) ]).take(8)).array;
}

// -------

Reply via email to