Array
Array is a fixed size data collection, which allows modification of values of its data members
(elements).
Elements of an array can be of any type; single array can contain elements of different types. Declaration of a
constant array in the code has the following format:
{a b c 1 2}
(elements are separated with a white spaces; elements are assumed to be words or numbers; [] i {}
used inside the array are treated as a nested lists and arrays).
Instructions item
and setitem
and indexing (,
) and assignment (:=
) operators are used to read or modify elements on
any position inside an array. Adding to or removing elements from an array is not possible, you should use
a list to do such operations on a data collection.
Example:
The for
loop is used to navigate backward through the elements in the array.
make "a newarray 5
print :a
for [i [count :a] 1] [:a,:i := repcount]
print :a
Output:
{0 0 0 0 0}
{5 4 3 2 1}
See also:
Array constructors:
array, newarray, genarray
Conversions:
listtoarray, arraytolist
Operations on data collections:
first, butfirst, last, butlast
count, emptyp, arrayp
apply
Table of Content