>>> head (1:>2:>3:>Nil)
1
>>> head Nil
<interactive>:...
Couldn't match type ‘...’ with ‘0’
Expected type: Vec ... a
Actual type: Vec 0 a
In the first argument of ‘head’, namely ‘Nil’
In the expression: head Nil

>>> last (1:>2:>3:>Nil)
3
>>> last Nil
<interactive>:...
Couldn't match type ‘...’ with ‘0’
Expected type: Vec ... a
Actual type: Vec 0 a
In the first argument of ‘last’, namely ‘Nil’
In the expression: last Nil

Forward permutation specified by an index mapping, ix. The result vector
is initialised by the given defaults, def, and an further values that are
permuted into the result are added to the current value using the given
combination function, f.

Copy elements from the source vector, xs, to the destination vector
according to an index mapping is. This is a forward permute operation where
a to vector encodes an input to output index mapping. Output elements for
indices that are not mapped assume the value in the default vector def.

Zipping

zipWith generalises zip by zipping with the function given
as the first argument, instead of a tupling function.
For example, "zipWith(+)" applied to two vectors produces the
vector of corresponding sums.

NB: "foldr f z xs" produces a linear structure, which has a depth, or
delay, of O(length xs). Use fold if your binary operator f is
associative, as "fold f xs" produces a structure with a depth of
O(log_2(length xs)).

NB: "foldl f z xs" produces a linear structure, which has a depth, or
delay, of O(length xs). Use fold if your binary operator f is
associative, as "fold f xs" produces a structure with a depth of
O(log_2(length xs)).

NB: "foldr1 f z xs" produces a linear structure, which has a depth,
or delay, of O(length xs). Use fold if your binary operator f is
associative, as "fold f xs" produces a structure with a depth of
O(log_2(length xs)).

NB: "foldl1 f z xs" produces a linear structure, which has a depth,
or delay, of O(length xs). Use fold if your binary operator f is
associative, as "fold f xs" produces a structure with a depth of
O(log_2(length xs)).

fold is a variant of foldr1 and foldl1, but instead of reducing from
right to left, or left to right, it reduces a vector using a tree-like
structure. The depth, or delay, of the structure produced by
"fold f xs", is hence O(log_2(length xs)), and not
O(length xs).

We thus need a fold function that can handle the growing vector type:
dfold. Compared to foldr, dfold takes an extra parameter, called the
motive, that allows the folded function to have an argument and result type
that depends on the current index into the vector. Using dfold, we can
now correctly define (++):

The mapAccumL function behaves like a combination of map and foldl;
it applies a function to each element of a vector, passing an accumulating
parameter from left to right, and returning a final value of this accumulator
together with the new vector.

The mapAccumR function behaves like a combination of map and foldr;
it applies a function to each element of a vector, passing an accumulating
parameter from right to left, and returning a final value of this accumulator
together with the new vector.

"windows2dstY stX xss", where matrix xss has stY + m rows of
stX + n, returns a matrix of m+1 rows of n+1 elements. The elements
of this new matrix are the overlapping (2D) windows of xss, where every
window has stY rows of stX elements.