Skip to content
Konjure / spatial intelligence

List

← Builtin reference

An ordered owned collection whose elements share one language type.

Signature

List[T]

List[T] stores Rust Vec<Value> data. The compiler retains T and the runtime checks elements at typed boundaries. An empty literal needs a contextual element type, such as let values: List[f64] = [];.

Indexing starts at zero and rejects out-of-range indices. Assignment copies a list value; .append(value) returns a new list. .get(index) returns Opt[T], while indexing returns Res[T, DataError]. Collection length and nested values remain subject to the embedding host's Limits.

Methods

len

len() -> f64

Returns the receiver's element, byte, or Unicode scalar count.

append

append(T) -> List[T]

Returns a new list with one value appended.

get

get(f64) -> Opt[T]

Returns Some(value) for a valid index and None otherwise.

Examples

Append without changing the original

append returns a new list. Change the appended value and compare both lists.

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

Rust definition

Value::List(Vec<Value>); static T and runtime validation enforce homogeneous elements.

See also