How about using std.random.randomSample?
2013/6/3 Yann <[email protected]> > Hey, > > I am trying to generate an array of 10 unique (!) random numbers from 1 to > 1000 each (for example). The best I could come up with is: > > auto arr = iota(1, 1000).array; > randomShuffle(arr); > return arr.take(10).array.sort; > > This leaves me quite unhappy, because I would like the code > a) to be one line > b) not use "array" more than once > > Is there a better way to accomplish this? Naively, I would expect > something like > "return iota(1, 1000).randomShuffle.take(10).**sort;" > > Thanks, > Yann >
