Skip to main content

Slice

Represents a range specification for indexing operations with start, stop, and step parameters.

Slice objects define ranges for accessing elements in containers, similar to Python slices. They specify a start index, stop index, and step size, allowing for flexible data access patterns including reverse iteration and skipping elements. Slices can be used with arrays, strings, and other indexable containers to extract subsequences or perform bulk operations.

Constructors

Slice() -> Slice

Constructs an empty Slice.

Slice(const Slice rhs) -> Slice

Slice copy constructor.

Parameters

  • rhs: The slice to copy from.

Slice(integer start, integer stop) -> Slice

Constructs a Slice with the specified start, stop values.

Parameters

  • start: The start index.
  • stop: The stop index.

Slice(integer start, integer stop, integer step) -> Slice

Constructs a Slice with the specified start, stop and step values.

Parameters

  • start: The start index.
  • stop: The stop index.
  • step: The step size (default is 1).

Symbols

NameDescription
=Assignment operator for Slice objects.

Members

NameDescription
resolveResolves the slice parameters for a given container size.
startReturns the start index of the slice.
stepReturns the step size of the slice.
stopReturns the stop index of the slice.