3.2.1.6 System.list
Implements: see System_object
Represents a list value.
Supported operators:
+
- Concatenate two lists (or a list and an object) together.
<
- Return true if the list on the left is less than the list on the right.
<=
- Return true if the list on the left is less than or equal to the list on the right.
==
- Tests two lists for equality.
>=
- Return true if the list on the left is greater than or equal to the list on the right.
>
- Return true if the list on the left is greater than the list on the right.
[]
- Returns the element at the given list index (beginning from 0)
<- (map)
- Map given method to each element of the list and return a new list containing the return value
of each call to said method. Method must take one parameter (the value of the current element).
<| (reduce)
- Call given method on each element of the list, given the result of the last call and the current
element of the list. Return the result of the last call of the method. Method must take two parameters–the
return value of the last method call (null if the first call) and the current element.
Supported methods:
str()
- Returns a string representation of the object (overridden; see System_object).
reset()
- Reset iterator in list (overridden; see System_object).
cur()
- Return current element pointed to by iterator (overridden; see System_object),
or
null
if the iterator is at the end of the list.
next()
- Move iterator to next element of list. Return
true
if successful, or false
if at the end of the list.
count()
- Return the number of elements in the list.
head()
- Return the first item of the list.
tail()
- Return a list containing all but the first element of the list.
append(value)
- Concatenate
value
, which can be a list or an individual object, to the end of the
list.
getIndex(index)
- Return the element at index
index
, beginning from 0.
prepend(value)
- Insert
value
at the beginning of the list.
sublist(from[, to])
- Return a list containing all the elements from the element at index
from
to
the (optional) element at index to
. If to
is not provided, return up
to the end of the list.
removeAt(index)
- Remove the element of the array at index
index
.