joka.ranges

The ranges module includes functions that work with ranges.

Types 13

A range that iterates over a numeric interval with a given step.

Fields
I index
I stop
I step
Methods
bool empty()
void popFront()
Constructors
this(I start, I stop, I step = 1)
structArrayRange(T)

A range that iterates over a read-only view of an array.

Fields
const(T)[] data
Sz index
Methods
bool empty()
T front()
void popFront()
T opIndex(Sz i)

A range that pairs each element of a range with its iteration index.

Fields
R range
Sz index
Methods
bool empty()
FrontType front()
void popFront()
structMapRange(R, F)

A range that applies a function to each element of a range.

Fields
R range
F func
Methods
bool empty()
auto front()
void popFront()
structFilterRange(R, F)

A range that skips elements of a range that do not satisfy a predicate.

Fields
R range
F func
Methods
void advance()
bool empty()
auto front()
void popFront()
Constructors
this(R range, F func)
structTakeRange(R)

A range that stops iteration after a given number of elements.

Fields
R range
Sz count
Methods
bool empty()
auto front()
void popFront()
structChainRange(R1, R2) if (is(typeof(R1.front()) == typeof(R2.front())))

A range that iterates over two ranges in sequence.

Fields
R1 a
R2 b
Methods
bool empty()
auto front()
void popFront()
structStrideRange(R)

A range that yields every Nth element of a range.

Fields
R range
Sz step
Methods
bool empty()
auto front()
void popFront()
structAccumulateRange(R, F, T)

A range that yields the running result of applying a function to all previous elements.

Fields
R range
F func
T result
Methods
bool empty()
T front()
void popFront()
Constructors
this(R range, F func, T initial)
structChunksRange(R)

A range that yields successive non-overlapping chunks of a given size.

Fields
R range
Sz size
Methods
bool empty()
auto front()
void popFront()
enumArgType : ubyte

Command-line argument types.

singleItemA standalone argument (e.g. file.txt)
shortOptionA short option (e.g. -v)
longOptionA long option (e.g. --verbose)
structArgToken

A parsed token from the command-line arguments.

Fields
ArgType type
IStr name
IStr value

A range of parsed tokens from the command-line arguments.

Fields
const(IStr)[] args
Methods
bool empty()
void popFront()
Constructors
this(const(IStr)[] args...)

Functions 22

fnArgTokenRange argTokens(const(IStr)[] args...) @safe nothrow @nogcReturns a command-line argument token range.
fnNumericRange!I range(I)(I start, I stop, I step = 1)Returns a numeric range.
fnArrayRange!T range(T)(const(T)[] data)Returns an array range.
fnEnumeratedRange!R enumerate(R)(R range, Sz start = 0)Returns a range that pairs each element with its iteration index.
fnMapRange!(R, F) map(R, F)(R range, F func)Returns a range that applies a function to each element.
fnFilterRange!(R, F) filter(R, F)(R range, F func)Returns a range that skips elements not satisfying a predicate.
fnT reduce(R, F, T)(R range, F func, T initial)Returns the result of applying a function cumulatively to all elements.
fnTakeRange!R take(R)(R range, Sz count)Returns a range that stops after a given number of elements.
fnR drop(R)(R range, Sz count)Returns a range with the first N elements skipped.
fnR dropWhile(R, F)(R range, F func)Returns a range with leading elements skipped while a predicate holds.
fnChainRange!(R1, R2) chain(R1, R2)(R1 range1, R2 range2)Returns a range that iterates over two ranges in sequence.
fnStrideRange!R stride(R)(R range, Sz step)Returns a range that yields every Nth element.
fnAccumulateRange!(R, F, T) accumulate(R, F, T)(R range, F func, T initial)Returns a range that yields the running result of applying a function cumulatively.
fnChunksRange!R chunks(R)(R range, Sz size)Returns a range that yields successive non-overlapping chunks of a given size.
fnauto min(T)(T range)Returns the smallest element in a range.
fnauto max(T)(T range)Returns the largest element in a range.
fnauto sum(T)(T range)Returns the sum of all elements in a range.
fnauto product(T)(T range)Returns the product of all elements in a range.
fnauto last(R)(R range)Returns the last element in a range.
fnbool any(R, F)(R range, F func)Returns true if any element satisfies a predicate.
fnbool all(R, F)(R range, F func)Returns true if all elements satisfy a predicate.
fnSz countIf(R, F)(R range, F func)Returns the number of elements satisfying a predicate.