Chunks an input range into subranges of equivalent adjacent elements. In other languages this is often called partitionBy, groupBy or sliceWhen.
Groups consecutively equivalent elements into a single tuple of the element and the number of its repetitions.
Lazily joins a range of ranges with a separator. The separator itself is a range. If a separator is not provided, then the ranges are joined directly without anything in between them (often called flatten in other languages).
Finds the mean (colloquially known as the average) of a range.
Lazily computes all permutations of r using Heap's algorithm.
Splits a forward range into subranges in places determined by a binary predicate.
Lazily splits a range using an element or range as a separator. Separator ranges can be any narrow string type or sliceable range type.
Lazily splits the character-based range s into words, using whitespace as the delimiter.
Returns a range with all occurrences of substs in r. replaced with their substitution.
Sums elements of r, which must be a finite input range. Although conceptually sum(r) is equivalent to fold!((a, b) => a + b)(r, 0), sum uses specialized algorithms to maximize accuracy, as follows.
Lazily iterates unique consecutive elements of the given range, which is assumed to be sorted (functionality akin to the _uniq system utility). Equivalence of elements is assessed by using the predicate pred, by default "a == b". The predicate is passed to std.functional.binaryFun, and can either accept a string, or any callable that can be executed via pred(element, element). If the given range is bidirectional, uniq also yields a bidirectional range.
Groups consecutively equivalent elements into a single tuple of the element and the number of its repetitions.
Lazily computes all permutations of r using Heap's algorithm.
Similar to fold, but returns a range containing the successive reduced values. The call cumulativeFold!(fun)(range, seed) first assigns seed to an internal variable result, also called the accumulator. The returned range contains the values result = fun(result, x) lazily evaluated for each element x in range. Finally, the last element has the same value as fold!(fun)(seed, range). The one-argument version cumulativeFold!(fun)(range) works similarly, but it returns the first element unchanged and uses it as seed for the next elements. This function is also known as partial_sum, accumulate, scan, Cumulative Sum.
Eagerly iterates over r and calls fun with each element.
filter!(predicate)(range) returns a new range containing only elements x in range for which predicate(x) returns true.
Similar to filter, except it defines a bidirectional range. There is a speed disadvantage - the constructor spends time finding the last element in the range that satisfies the filtering condition (in addition to finding the first one). The advantage is that the filtered range can be spanned from both directions. Also, std.range.retro can be applied against the filtered range.
Implements the homonym function (also known as accumulate, compress, inject, or foldl) present in various programming languages of functional flavor, iteratively calling one or more predicates.
Implements the homonym function (also known as transform) present in many languages of functional flavor. The call map!(fun)(range) returns a range of which elements are obtained by applying fun(a) left to right for all elements a in range. The original ranges are not changed. Evaluation is done lazily.
Implements the homonym function (also known as accumulate, compress, inject, or foldl) present in various programming languages of functional flavor. There is also fold which does the same thing but with the opposite parameter order. The call reduce!(fun)(seed, range) first assigns seed to an internal variable result, also called the accumulator. Then, for each element x in range, result = fun(result, x) gets evaluated. Finally, result is returned. The one-argument version reduce!(fun)(range) works similarly, but it uses the first element of the range as the seed (the range must be non-empty).
Returns a range with all occurrences of substs in r. replaced with their substitution.
This is a submodule of std.algorithm. It contains generic iteration algorithms.