init::list

init/src/list.mo

defList.length#
pub def List.length {A : Type} (xs : List A) : I64

The number of elements. Structural recursion with the direct I64 native: + would go through the Add instance and allocate a dictionary lookup per element in the compiled backend.

defList.get#
pub def List.get (index : I64) (l : List A) : Option A

Get the element at index. Negative and out-of-range indices are none. The walk uses the direct I64 natives: the previous version stepped with ==, BOrd.gt and -, whose class dispatch allocates a dictionary lookup per element in the compiled backend.