Skip to content
Konjure / spatial intelligence

range

← Builtin reference

Creates a bounded sequence of exactly representable integer Numbers from start inclusive to end exclusive.

Signature

func range(end: Number) -> Res[List[Number], DataError]
func range(start: Number, end: Number) -> Res[List[Number], DataError]

Each bound must be finite, integral, and exactly representable from -9007199254740991 through 9007199254740991. End is exclusive; descending bounds produce an empty list. Invalid endpoints return DataError; a host resource limit remains a Diagnostic.

Parameters

end: f64
Exactly representable finite integer from -9007199254740991 through 9007199254740991; it is exclusive.
start: f64
Exactly representable finite integer from -9007199254740991 through 9007199254740991; omitted start is zero.

Returns

Res[List[f64], DataError]

Ok(List[Number]) for valid endpoints, Err(DataError) for invalid numeric endpoints. A host resource limit rejects execution diagnostically.

Examples

Range from zero

One bound starts at zero.

Tick 0 · 0.00 s⌘ / Ctrl + EnterThis device
main.kj
Loading the language runtime…
Output 0
No output.
Expected output
3

Range with bounds

The start is inclusive and end is exclusive.

Tick 0 · 0.00 s⌘ / Ctrl + EnterThis device
main.kj
Loading the language runtime…
Output 0
No output.
Expected output
3

Rust definition

Rust interpreter builtin dispatch; one- and two-argument Number overloads return Res[List[Number], DataError] for invalid numeric endpoints.

See also