Algosim documentation: VarTruncate

VarTruncate

Truncates a linear container variable.

Syntax

If X is an lvalue and a container and n a non-negative integer, then VarTruncate(X, n) truncates X to length n. This means that if #X > n initially, trailing elements are removed from X until it has reached length n. If initially #X ≤ n, X is left unchanged. If successful, VarTruncate returns success.

This is the procedural version of truncate.

Examples

v ≔ SequenceVector(10)
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
VarTruncate(v, 5)
success
v
 ⎛1⎞
 ⎜2⎟
e⎜3⎟
 ⎜4⎟
 ⎝5⎠

See also