Re: Trying to understand RandomSample struct in std.random

2012-04-12 Thread Ali Çehreli
On 04/12/2012 01:27 PM, Joseph Rushton Wakeling wrote: > What I _still_ don't understand is the statement in the constructor: > > // we should skip some elements initially so we don't always > // start with the first > > ... as it seems to me that doing so would bugger up the selection > algorith

Re: Trying to understand RandomSample struct in std.random

2012-04-12 Thread Joseph Rushton Wakeling
On 12/04/12 20:39, Ali Çehreli wrote: That's misleading. RandomSample is a lazy range. The output seems to be elements of an array only as you pull data out of this range. Ahhh, it's lazy evaluation. That would explain why you can set ret.gen = gen in the randomSample functions and have it wo

Re: Trying to understand RandomSample struct in std.random

2012-04-12 Thread Ali Çehreli
On 04/12/2012 11:30 AM, Joseph Rushton Wakeling wrote: > What gets output at the end is clearly an array containing a subset of > the original input. That's misleading. RandomSample is a lazy range. The output seems to be elements of an array only as you pull data out of this range. > The con

Trying to understand RandomSample struct in std.random

2012-04-12 Thread Joseph Rushton Wakeling
Hello all, I'm trying to understand the internal operations of the RandomSample struct in std.random. What gets output at the end is clearly an array containing a subset of the original input. But I can't understand how this is constructed. The constructor sets various initial values and t