Skip to main content

Mojo struct

StridedSlice

struct StridedSlice

Represents a slice expression that has a stride.

This type is used to support different behavior for strided vs unstrided slicing.

Implemented traits

AnyType, Copyable, ImplicitlyCopyable, Movable, UnknownDestructibility

Aliases

__copyinit__is_trivial

comptime __copyinit__is_trivial = False

__del__is_trivial

comptime __del__is_trivial = False

__moveinit__is_trivial

comptime __moveinit__is_trivial = False

Methods

__init__

__init__(out self, start: Optional[Int], end: Optional[Int], stride: Int)

Construct slice given start, end, and stride values.

Args:

  • start (Optional): The start value.
  • end (Optional): The end value.
  • stride (Int): The step value.

indices

indices(self, length: Int) -> Tuple[Int, Int, Int]

Returns a tuple of 3 integers representing start, end, and step of the slice if applied to a container of given length.

Args:

  • length (Int): The length of the target container.

Returns:

Tuple: A tuple containing three integers for start, end, and step.

Was this page helpful?