Nanyx
PlaygroundPackages

prelude: arrays

Reading an element of an array, which calling the array does

The part of an array’s functions that is in the prelude, so no import is needed: what calling an array reads, xs(i). The rest of them are in nanyx/array.

Reference

array.at

def array.at: array(a), int -> #some(a) | #notFound

The element of xs at index, counting from 0, or #notFound when index is negative or past the end. Calling the array, xs(index), is the same.

array.fromArray

def array.fromArray: array(a) -> array(a)

xs itself. What a literal builds an array with, Array[1, 2], or [1, 2] where an array is expected.

list.fromArray

def list.fromArray: array(a) -> list(a)

The elements of xs, in order. What a literal builds a list with where it is written List[...].

array.toSeq

def array.toSeq: array(a) -> seq(a)

The elements of xs, in order, each read when the sequence is pulled. An array is Iterable by it, so a for loop walks one.