Vector

Vector is an array-like type that supports length/bounds checking at type-level. It also implements the dimensional interfaces and supports generic programming.

=

defn

(Fn [(Vector a b), (Vector a b)] Bool)

                    (= vector-a vector-b)
                

copy

template

(Fn [(Ref (Vector a b) c)] (Vector a b))

copies the Vector.

delete

template

(Fn [(Vector a b)] ())

deletes a Vector. Should usually not be called manually.

empty

defn

(Fn [] (Vector Zero a))

                    (empty)
                

Returns an empty Vector

defn

(Fn [(Ref (Vector (Size a) b) c)] b)

                    (head v)
                

Returns the first element of a Vector.

init

template

(Fn [(Array a)] (Vector b a))

creates a Vector.

iota

defn

(Fn [(Ref (Vector (Size a) b) c)] (Vector (Size a) (Index (Vector (Size a) Opaque) Int)))

                    (iota v)
                

last

defn

(Fn [(Ref (Vector (Size a) b) c)] b)

                    (last v)
                

Returns the last element of a Vector.

lookup

defn

(Fn [(Vector (Size a) b)] (Fn [(Index (Vector (Size a) Opaque) Int)] b))

                    (lookup v)
                

map

defn

(Fn [(Ref (Fn [a] b) c), (Ref (Vector (Size d) a) e)] (Vector (Size d) b))

                    (map f v)
                

 Maps a function `f` over all the elements of a Vector and returns a new
 Vector containing the results.

nth

defn

(Fn [(Ref (Vector (Size a) b) c), (Index (Vector (Size a) Opaque) Int)] b)

                    (nth v ix)
                

Retrieves the nth element of a Vector using a given `Index`.

The given `Index` must have a `Size` equivalent to the `Vector`'s size in
its first position (the bound position).

If the `Index`'s Int value exceeds the length of the Vector, this
function will return the last element of the Vector.

of

macro

Macro

                    (of values)
                

Creates a new Vector from the contents of an Array literal.

positions

defn

(Fn [] (Vector (Size a) (Index (Vector (Size a) Opaque) Int)))

                    (positions)
                

prn

template

(Fn [(Ref (Vector a b) c)] String)

converts a Vector to a string.

push

defn

(Fn [a, (Ref (Vector b a) c)] (Vector (Size b) a))

                    (push x v)
                

Adds an element to the end of a Vector, returning a new Vector.

ref-eq

defn

(Fn [(Ref (Vector a b) c), (Ref (Vector a b) d)] Bool)

                    (ref-eq vector-a vector-b)
                

str

template

(Fn [(Ref (Vector a b) c)] String)

converts a Vector to a string.

tail

defn

(Fn [(Ref (Vector (Size a) b) c)] (Vector a b))

                    (tail v)
                

Returns all but the first element of a Vector as a new Vector.

to-array

defn

(Fn [(Ref (Vector a b) c)] (Array b))

                    (to-array v)
                

Converts a Vector to an Array.

zip

defn

(Fn [(Ref (Fn [a, b] c) d), (Ref (Vector e a) f), (Ref (Vector e b) g)] (Vector e c))

                    (zip f v v1)
                

Combines two Vectors using a binary function `f`.