return to top
source
Insert an element into a vector at a given position.
Reading insertAt x v i at the insertion position i returns the inserted element x.
insertAt x v i
i
x
After inserting x at Fin.last n, reading the result at i.castSucc returns the original entry v[i].
Fin.last n
i.castSucc
v[i]
Inserting an element at index xs.length is the same as appending it.
xs.length
Vector.map commutes with Vector.toList.
Vector.map
Vector.toList
insertAt x v (Fin.last n) appends x to the end of v.toList.
insertAt x v (Fin.last n)
v.toList
insertAt x v i corresponds to List.insertIdx at position i on the underlying list.
List.insertIdx