Mojo function
range
range[T: Indexer, //](end: T) -> _ZeroStartingRange
Constructs a [0; end) Range.
Parameters:
- T (
Indexer
): The type of the end value.
Args:
- end (
T
): The end of the range.
Returns:
The constructed range.
range[T: IntableRaising, //](end: T) -> _ZeroStartingRange
Constructs a [0; end) Range.
Parameters:
- T (
IntableRaising
): The type of the end value.
Args:
- end (
T
): The end of the range.
Returns:
The constructed range.
Raises:
An error if the conversion to an Int
failed.
range(end: PythonObject) -> _ZeroStartingRange
Constructs a [0; end) Range from a Python int
.
Args:
- end (
PythonObject
): The end of the range as a Pythonint
.
Returns:
The constructed range.
Raises:
An error if converting end
to an Int
failed.
range[T0: Indexer, T1: Indexer, //](start: T0, end: T1) -> _SequentialRange
Constructs a [start; end) Range.
Parameters:
- T0 (
Indexer
): The type of the start value. - T1 (
Indexer
): The type of the end value.
Args:
- start (
T0
): The start of the range. - end (
T1
): The end of the range.
Returns:
The constructed range.
range[T0: IntableRaising, T1: IntableRaising](start: T0, end: T1) -> _SequentialRange
Constructs a [start; end) Range.
Parameters:
- T0 (
IntableRaising
): The type of the start value. - T1 (
IntableRaising
): The type of the end value.
Args:
- start (
T0
): The start of the range. - end (
T1
): The end of the range.
Returns:
The constructed range.
Raises:
An error if converting start
or end
to an Int
failed.
range(start: PythonObject, end: PythonObject) -> _SequentialRange
Constructs a [start; end) Range from Python int
objects.
Args:
- start (
PythonObject
): The start of the range as a Pythonint
. - end (
PythonObject
): The end of the range as a Pythonint
.
Returns:
The constructed range.
Raises:
An error if converting start
or end
to an Int
failed.
range[T0: Indexer, T1: Indexer, T2: Indexer, //](start: T0, end: T1, step: T2) -> _StridedRange
Constructs a [start; end) Range with a given step.
Parameters:
- T0 (
Indexer
): The type of the start value. - T1 (
Indexer
): The type of the end value. - T2 (
Indexer
): The type of the step value.
Args:
- start (
T0
): The start of the range. - end (
T1
): The end of the range. - step (
T2
): The step for the range.
Returns:
The constructed range.
range[T0: IntableRaising, T1: IntableRaising, T2: IntableRaising, //](start: T0, end: T1, step: T2) -> _StridedRange
Constructs a [start; end) Range with a given step.
Parameters:
- T0 (
IntableRaising
): The type of the start value. - T1 (
IntableRaising
): The type of the end value. - T2 (
IntableRaising
): The type of the step value.
Args:
- start (
T0
): The start of the range. - end (
T1
): The end of the range. - step (
T2
): The step for the range.
Returns:
The constructed range.
Raises:
An error if converting start
, end
, or step
to an Int
failed.
range(start: PythonObject, end: PythonObject, step: PythonObject) -> _StridedRange
Constructs a [start; end) Range from Python int
objects with a given step.
Args:
- start (
PythonObject
): The start of the range as a Pythonint
. - end (
PythonObject
): The end of the range as a Pythonint
. - step (
PythonObject
): The step for the range as a Pythonint
.
Returns:
The constructed range.
Raises:
An error if converting start
, end
, or step
to an Int
failed.
range(end: UInt) -> _UIntZeroStartingRange
Constructs a [0; end) Range.
Args:
- end (
UInt
): The end of the range.
Returns:
The constructed range.
range(start: UInt, end: UInt, step: UInt = UInt(1)) -> _UIntStridedRange
Constructs a [start; end) Range with a given step.
Args:
- start (
UInt
): The start of the range. - end (
UInt
): The end of the range. - step (
UInt
): The step for the range. Defaults to 1.
Returns:
The constructed range.
range[dtype: DType, //](end: SIMD[dtype, 1]) -> _ZeroStartingScalarRange[dtype]
Constructs a [start; end) Range with a given step.
Parameters:
- dtype (
DType
): The range dtype.
Args:
- end (
SIMD[dtype, 1]
): The end of the range.
Returns:
The constructed range.
range[dtype: DType, //](start: SIMD[dtype, 1], end: SIMD[dtype, 1]) -> _SequentialScalarRange[dtype]
Constructs a [start; end) Range with a given step.
Parameters:
- dtype (
DType
): The range dtype.
Args:
- start (
SIMD[dtype, 1]
): The start of the range. - end (
SIMD[dtype, 1]
): The end of the range.
Returns:
The constructed range.
range[dtype: DType, //](start: SIMD[dtype, 1], end: SIMD[dtype, 1], step: SIMD[dtype, 1]) -> _StridedScalarRange[dtype]
Constructs a [start; end) Range with a given step.
Parameters:
- dtype (
DType
): The range dtype.
Args:
- start (
SIMD[dtype, 1]
): The start of the range. - end (
SIMD[dtype, 1]
): The end of the range. - step (
SIMD[dtype, 1]
): The step for the range. Defaults to 1.
Returns:
The constructed range.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!