Darwin Help

Back to Index

list

Class list - list or array of arbitrary elements

Calling Sequence  []
[a]
[a,...]
Parameters
NameTypeDescription

a anything 
Return Type  list
Selectors
NameTypeDescription

the ith element in the list 
.. a sublist of elements from the list 
Methods power, Rand, Row, Table
Synopsis A list holds arbitrary values or structures. Elements in the list are left in the order the list was created. A list is also an array. A list of lists (of the same length) is a matrix. Elements of a list can be replaced with an assignment statement. Arithmetic operations work on lists (arrays) and lists of lists (matrices) according to the normal rules of linear algebra. (See examples) As an array, the list has no interpretation of column or row. It will act as column or row depending on the operation performed on it. When selecting with an integer range, negative values are interpreted as counting from the right. I.e. -2..-1 select the last two elements of the list.
Examples
> a := [b,1,2,2];
a := [b, 1, 2, 2]
> a[1];
b
> a[1..2];
[b, 1]
> a[-1..-1];
[2]
> a[-2..-1];
[2, 2]
> a[3] := 77;
a[3] := 77
> a;
[b, 1, 77, 2]
> A := [[1,2],[3,0]];
A := [[1, 2], [3, 0]]
> V := [-2,3];
V := [-2, 3]
> A*V;
[4, -6]
> V*A;
[7, -4]
> 2*A;
[[2, 4], [6, 0]]
> A/3;
[[0.3333, 0.6667], [1, 0]]
> 7*V;
[-14, 21]
> V/5;
[-0.4000, 0.6000]
> V*V;
13
> B := 1/A;
B := [[0, 0.3333], [0.5000, -0.1667]]
> A*B;
[[1, 0], [0, 1]]
> V+[0,1];
[-2, 4]


See also append,   CreateArray,   matrix,   member,   mselect,   set,   subset