arange
Creates a 1D array of evenly spaced values within the half-open interval [start, stop). The spacing between values is controlled by step, which can be an integer or a double.
Signatures
With start
inline fun <reified T : Number> Multik.arange(
start: Int, stop: Int, step: Int = 1
): D1Array<T>
inline fun <reified T : Number> Multik.arange(
start: Int, stop: Int, step: Double
): D1Array<T>
Without start (starts at 0)
inline fun <reified T : Number> Multik.arange(
stop: Int, step: Int = 1
): D1Array<T>
inline fun <reified T : Number> Multik.arange(
stop: Int, step: Double
): D1Array<T>
Parameters
Parameter | Type | Default | Description |
|---|---|---|---|
|
|
| Start of interval (inclusive). |
|
| — | End of interval (exclusive). |
|
|
| Spacing between values. |
Returns: D1Array<T> with values [start, start + step, start + 2*step, …) up to but not including stop.
Example
val a = mk.arange<Int>(5) // [0, 1, 2, 3, 4]
val b = mk.arange<Int>(2, 10, 3) // [2, 5, 8]
val c = mk.arange<Double>(0, 1, 0.3) // [0.0, 0.3, 0.6, 0.9]
Constraints
If
start < stop,stepmust be positive.If
start > stop,stepmust be negative.stepmust not be zero.
28 February 2026