Nasal library functions: Difference between revisions

Jump to navigation Jump to search
Line 20: Line 20:


== setsize() ==
== setsize() ==
'''Usage:'''
setsize(vect, new_size)
where ''vect'' is an expression which evaluates to a vector and ''new_size'' is an expression that evaluates to a non-negative number.
'''Action:'''
Changes the number of elements in the vetor ''v'' to the value of s.
'''Return value:'''
The resized vector.
'''Notes'''
Elements that exist in both the original and the resized vector retain their values. When the vector is enlarged newly created elements are set to ''nil''. When the size is reduced the values of all elements beyond the new size are permanently lost.
The ''new_size'' argument may be any non-negative number. Non-integer values are rounded down.
The ''vect'' argument need not be a named variable. The expression:
var v1 = setsize([], n);
Is a convenient way to allocate an empty vector of a specific size.


== subvec() ==
== subvec() ==
15

edits

Navigation menu