Progress the random sequency next_size creates a new sequency
import std.algorithm; import std.range; import std.stdio; alias RandomT = Random!uint; enum sample = 5; { // Simple range of sequences with fixed size auto start = RandomT(1234); auto rand_range = recurrence!(q{ a[n-1].drop(3) })(start); assert(equal( rand_range .take(sample) .map!q{a.take(3)} .joiner, start.save .take(sample * 3))); } { // Range of sequences with random size auto start = RandomT(1234); // Generate sequency range with variable size in the range 4..8 auto rand_range = recurrence!( (a, n) => a[n - 1].progress(start.value(4, 8)) )(Sequence!uint(start.save, 5)); // Store the begen of the random start auto begin = start; const total_number = rand_range.take(sample).map!q{a.size}.sum; // restore start random auto expected = start = begin; assert(equal(expected.take(total_number), rand_range.take(sample).map!q{a.list}.joiner)); }
This data type can be used to group a sequence of pseudo random sequency