The D language Standard library explains the range in the following way:
Ranges generalize the concept of arrays,lists, or anything that involves sequential access
Meaning that the range summarizes the array, the list, or any concept that involves sequential access, let's call it a sequence set to differentiate between aggregate (iteration set) and sets (key-value set).
Package file RANGE.D
First,
chain
function
Concatenate several sequence sets into a sequence set.
ImportStd.stdio;ImportStd.range;intMain (string[] argv) {int[] A = [A.]; int[] B = [4,5,6]; Auto C=Chain (A, b); Writeln ("C Len:", c.length); Writeln ("C:", c); Writeln ("C type is:", typeID (c)); Writeln ("C[0]:", c[0]); Writeln ("C[3]:", c[3]); Writeln ("Items List:"); foreach (i;c) {writeln (i); } readln (); return0;}
From the running results, chain is to concatenate two arrays into an object of type Std.range.chain (int[],int[]). Chain. The result type.
This single object can be handled using a foreach operation. You can also use the index to access, very good things, it looks like more than the IEnumerable function in C #, but the IEnumerable of the abstraction is higher, there is no requirement for sequential access and number of elements, only requires the ability to iterate, perhaps aggregate refers to the concept.
IEnumerable only requires the ability to enumerate elements, which is important, because many times, it is not necessary to require data to be in memory, such as access to database records, the data is probably not in memory, if there is a number of requirements, then the range is not very good processing database data access problems.
Therefore, range can only be called a sequence set, not an enumeration set, or an iteration set. The sequence set should also be a part of the iteration set, since range is one of the iteration sets, so how does he implement the foreach access? A question of value research.
Use of range sequence set in D language