Selecting Elements
Select elements at a particular interval, the first mapped value, or iterate of elements with their indices.
Selecting Elements at an Interval
func striding(by: Int
) -> StridingSequence<Self> Returns a sequence stepping through the elements every
step
starting at the first value. Any remainders of the stride will be trimmed.func striding(by: Int
) -> StridingCollection<Self> Returns a sequence stepping through the elements every
step
starting at the first value. Any remainders of the stride will be trimmed.
Conditionally Finding the First Mapped Value
func firstNonNil<Result>((Element) throws -> Result?
) rethrows -> Result? Returns the first non-
nil
result obtained from applying the given transformation to the elements of the sequence.
Iterating Over Elements with Their Indices
func indexed(
) -> IndexedCollection<Self> Returns a collection of pairs (i, x), where i represents an index of the collection, and x represents an element.
Supporting Types
struct IndexedCollection<Base>
A collection wrapper that iterates over the indices and elements of a collection together.
struct StridingSequence<Base>
A wrapper that strides over a base sequence.
struct StridingCollection<Base>
A wrapper that strides over a base collection.