Basic operations on Lists include assignment, concatenation, conversions, length, and comparisons.
Assignment for Lists is done with the assignment (
L1 = L2; destroys the
contents of List
L1 and replaces them with a
copy of the elements in List
The return value of an assignment expression is the object assigned, so
L1=L2=L3; works as expected.
The plus (
+) operator is used for concatenation.
are both Lists, then
L1 + L2 is a new List whose
elements are a copy of those of
L1 followed by
a copy of those of
can be used with a List and a T, so that
a new List whose elements are those of List
Coercions from Ts to
List<T>s are implemented
by the constructor functions for class
For example, whenever a T is found where a
is expected, the appropriate
function is called to produce a List containing just that element.
Also, whenever a List is used as an expression, for example,
while(L), it is converted to a
automatically so that it can be evaluated as TRUE or FALSE.
The expression will
be TRUE if the List is nonempty, and FALSE otherwise.
L.length() returns the length (number of
elements) of the
The == and != operators are used for comparisons of Lists.
L1 == L2 is TRUE if each element of
L1 is equal (that is,
is nonzero) to the corresponding element of
L1 != L2 is TRUE otherwise.