| Applying science to business management |
  
List Operators
Almost all operators will accept lists as operands. For
example, if you supply lists as operands to the Add operator, it will add all
corresponding elements in the lists. However, several operators
are designed exclusively to manipulate lists.
List Literal [x,y,...]
You can create a list simply by enclosing a list of
expressions in square brackets. For example, [1,2,3,4] will
create a list of the four numbers 1 to 4.
Range x..y
The Range operator provides a way to create a list of
consecutive integers. For example, the expression 1..4 is the same as [1,2,3,4]. Similarly, 4..1 is the same as [4,3,2,1].
List Concatenate x!!y
This operator is used to combine two lists into a single,
large list. For example, the expression [1,2,]!![3,4]
is the same as [1,2,3,4]. Note
that the expression x!!y is not
the same as [x,y]. The latter
expression adds a new dimension to the lists x and y
while the first expression does not.
List Element x[y]
Once you have created a list, the List Element operator
can be used to access particular elements. For example, x[0] is the first element in the list
named x. Similarly, x[4] is the fifth element. Note that
the index number y is zero-based.
If you supply a list of elements for the operand y, then the result will be a list of
elements. For example, x[0..4]
will return a list containing the first five elements in x.
If x is a two dimensional
array such as [[1,2,3],[4,5,6]],
then you can access particular elements using an expression such
as x[0][2]. This expression
represents the third element in the first list in x, (3).
Subscript x#y
The Subscript operator is works just like the List Element operator except that
the element index is one-based. For example, x#1 is the first element in x and x#5
is the fifth.
Just as with the List Element
operator, the Subscript operator will accept a list of
index numbers in y (e.g., x#1..5) and can be used to access
elements in multi-dimensional arrays (e.g., x#1#3).
delete delete x[y]
You can use the delete operator to delete specific elements in
a list. For example,
var list=1..5; // list =
[1,2,3,4,5]
delete list[2]; // list =
[1,2,4,5]
|