std/core/vector▲toc

Standard vector functions.

.

fun list/vector( xs : liststd/core/types/list: V -> V<a> ) : vectorstd/core/types/vector: V -> V<a>

Convert a list to a vector.

fun unit/vector(): vectorstd/core/types/vector: V -> V<a>

Create an empty vector.

fun at( ^v : vectorstd/core/types/vector: V -> V<a>, ^index : intstd/core/types/int: V ) : maybestd/core/types/maybe: V -> V<a>

Return the element at position index in vector v, or Nothingstd/core/types/Nothing: forall<a> maybe<a> if out of bounds.

fun foreach( v : vectorstd/core/types/vector: V -> V<a>, f : (a) -> e () ) : e ()

Invoke a function f for each element in a vector v.

fun foreach-indexed( v : vectorstd/core/types/vector: V -> V<a>, f : (intstd/core/types/int: V, a) -> e () ) : e ()

Invoke a function f for each element in a vector v.

fun foreach-while( v : vectorstd/core/types/vector: V -> V<a>, f : (a) -> e maybestd/core/types/maybe: V -> V<b> ) : e maybestd/core/types/maybe: V -> V<b>

Invoke a function f for each element in a vector v. If f returns Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>, the iteration is stopped early and the result is returned.

fun length( ^v : vectorstd/core/types/vector: V -> V<a> ) : intstd/core/types/int: V

Return the length of a vector.

fun list( v : vectorstd/core/types/vector: V -> V<a> ) : liststd/core/types/list: V -> V<a>

Convert a vector to a list.

fun map( v : vectorstd/core/types/vector: V -> V<a>, f : (a) -> e b ) : e vectorstd/core/types/vector: V -> V<b>

Apply a function f to each element in a vector v.

fun vector( ^n : intstd/core/types/int: V, default : a ) : vectorstd/core/types/vector: V -> V<a>

Create a new vector of length n with initial elements defaultstd/core/exn/default: forall<a> (t : error<a>, def : a) -> a .

fun vector-init( ^n : intstd/core/types/int: V, f : (intstd/core/types/int: V) -> e a ) : e vectorstd/core/types/vector: V -> V<a>

Create a new vector of length n with initial elements given by function f which can have a control effect.

fun vector-init-total( ^n : intstd/core/types/int: V, f : (intstd/core/types/int: V) -> a ) : vectorstd/core/types/vector: V -> V<a>

Create a new vector of length n with initial elements given by total function f. (can be more efficient than vector-initstd/core/vector/vector-init: forall<a,e> (n : int, f : (int) -> e a) -> e vector<a>).

fun vlist( v : vectorstd/core/types/vector: V -> V<a>, tail : ? (liststd/core/types/list: V -> V<a>) ) : liststd/core/types/list: V -> V<a>

Convert a vector to a list with an optional tail.

private import std/core/typesstd/core/types, std/core/undivstd/core/undiv, std/core/hndstd/core/hnd, std/core/exnstd/core/exn, std/core/intstd/core/int