iota

fnauto iota(B, E, S)(B begin, E end, S step) if ((isIntegral!(CommonType!(B, E)) || isPointer!(CommonType!(B, E))) && isIntegral!S)

Creates a range of values that span the given starting and stopping values.

Parameters

beginThe starting value.
endThe value that serves as the stopping criterion. This value is not included in the range.
stepThe value to add to the current value at each iteration.

Returns

A range that goes through the numbers begin, begin + step, begin + 2 * step, `...`, up to and excluding end.

The two-argument overloads have step = 1. If begin < end && step < 0 or begin > end && step > 0 or begin == end, then an empty range is returned. If step == 0 then begin == end is an error.

For built-in types, the range returned is a random access range. For user-defined types that support `++`, the range is an input range.

in operator and contains: iota over an integral/pointer type defines the in operator from the right. val in iota(...) is true when val occurs in the range. When present, it takes step into account - val won't be considered contained if it falls between two consecutive elements of the range. The contains method does the same as in, but from the left-hand side.

Example:

void main()
{
    import std.stdio;

    // The following groups all produce the same output of:
    // 0 1 2 3 4

    foreach (i; 0 .. 5)
        writef("%s ", i);
    writeln();

    import std.range : iota;
    foreach (i; iota(0, 5))
        writef("%s ", i);
    writeln();

    writefln("%(%s %|%)", iota(0, 5));

    import std.algorithm.iteration : map;
    import std.algorithm.mutation : copy;
    import std.format;
    iota(0, 5).map!(i => format("%s ", i)).copy(stdout.lockingTextWriter());
    writeln();
}

fnauto iota(B, E)(B begin, E end) if (isFloatingPoint!(CommonType!(B, E)))

Ditto

fnauto iota(B, E)(B begin, E end) if (isIntegral!(CommonType!(B, E)) || isPointer!(CommonType!(B, E)))

Ditto

fnauto iota(E)(E end) if (is(typeof(iota(E(0), end))))

Ditto

fnauto iota(B, E, S)(B begin, E end, S step) if (isFloatingPoint!(CommonType!(B, E, S)))

Ditto

fnauto iota(B, E)(B begin, E end) if (!isIntegral!(CommonType!(B, E)) && !isFloatingPoint!(CommonType!(B, E)) && !isPointer!(CommonType!(B, E)) && is(typeof((ref B b) { ++ b; })) && (is(typeof(B.init < E.init)) || is(typeof(B.init == E.init))) )

ditto