stride

Strides 1-dimensional slice.

  1. auto stride(Slice!(Iterator, N, kind) slice, ptrdiff_t factor)
    @optmath
    stride
    (
    Iterator
    size_t N
    SliceKind kind
    )
    (
    Slice!(Iterator, N, kind) slice
    ,
    ptrdiff_t factor
    )
    if (
    N == 1
    )
  2. template stride(size_t factor = 2)
  3. auto stride(T[] array, ptrdiff_t factor)
  4. auto stride(T withAsSlice, ptrdiff_t factor)

Parameters

slice Slice!(Iterator, N, kind)

1-dimensional unpacked slice.

factor ptrdiff_t

positive stride size.

Return Value

Type: auto

Contiguous slice with strided iterator.

Examples

auto slice = iota(6);
static immutable str = [0, 2, 4];
assert(slice.stride(2) == str); // runtime factor
assert(slice.stride!2 == str); // compile time factor
assert(slice.stride == str); // default compile time factor is 2
assert(slice.universal.stride(2) == str);

ND-compile time

auto slice = iota(4, 6);
static immutable str = [[0, 2, 4], [12, 14, 16]];
assert(slice.stride!2 == str); // compile time factor
assert(slice.stride == str); // default compile time factor is 2

See Also

Meta