Algosim documentation: VarInsert

VarInsert

Insert an object into a container variable.

Syntax

If X is an lvalue and a container, i a valid index in a container of size #X + 1, and x a value that can be part of X, then VarInsert(X, i x) inserts x at index i in X (so that i becomes the index of x in X after the insertion). VarInsert returns success if successful.

This is the procedural version of insert.

Examples

v ≔ SequenceVector(10)
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
VarInsert(v, 5, 100)
success
v
(1, 2, 3, 4, 100, 5, 6, 7, 8, 9, 10)

See also