Ranges and random numbers -- again
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Mon Jun 17 15:29:24 PDT 2013
On 06/17/2013 11:18 PM, Joseph Rushton Wakeling wrote:
>> A random range should be viewed (IMO) as nothing more than a range that "was"
>> (conceptually) simply filled with random numbers. Calling front on the same
>> range twice in a row *should* produce the same result: No call to popFront => no
>> change to the range. If it did change, it'd be a blatant violation of the range
>> concept. It also means you can't have safe/nothrow/pure/const "front".
>
> Completely agree, and I don't think this is in contradiction with what I've
> proposed. My proposed "rule" might be better stated to clarify this.
Perhaps this would be a better statement:
************************************************************************
* Iterating fully over a given random range should produce a different *
* sequence for each such complete iteration. *
************************************************************************
So, if you do,
SomeRandomRange r;
x = r.front;
y = r.front;
assert(x == y); // Passes!!
But
SomeRandomRange r;
arr1 = array(r);
arr2 = array(r);
assert(x != y); // the two arrays are filled with different sequences.
More information about the Digitalmars-d
mailing list