list¶
type list < sequence
A list of elements.
meth list(Sequence: sequence, ...): list
Returns a list of all of the values produced by
Sequence
.list(1 .. 10) :> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
meth list(): list
Returns an empty list.
list() :> []
meth list(Tuple: tuple): list
Returns a list containing the values in
Tuple
.list((1, 2, 3)) :> [1, 2, 3]
meth (List₁: list) + (List₂: list): list
Returns a new list with the elements of
List₁
followed by the elements ofList₂
.meth (List: list)[Index: integer]: list::node | nil
Returns the
Index
-th node inList
ornil
ifIndex
is outside the range ofList
. Indexing starts at1
. Negative indices are counted from the end of the list, with-1
returning the last node.let L := ["a", "b", "c", "d", "e", "f"] L[3] :> "c" L[-2] :> "e" L[8] :> nil
meth (List: list)[Indices: list::mutable]: list
Returns a list containing the
List[Indices[1]]
,List[Indices[2]]
, etc.meth (List: list):count: integer
Returns the length of
List
[1, 2, 3]:count :> 3
meth (List: list):find(Value: any): integer | nil
Returns the first position where
List[Position] = Value
.meth (List: list):first
Returns the first value in
List
ornil
ifList
is empty.meth (List: list):last
Returns the last value in
List
ornil
ifList
is empty.meth (List: list):length: integer
Returns the length of
List
[1, 2, 3]:length :> 3
meth (List: list):precount: integer
Returns the length of
List
[1, 2, 3]:count :> 3
meth (List: list):random: any
Returns a random (assignable) node from
List
.let L := list("cake") :> ["c", "a", "k", "e"] L:random :> "k" L:random :> "k"
meth (Buffer: string::buffer):append(List: list)
Appends a representation of
List
toBuffer
of the form"[" + repr(V₁) + ", " + repr(V₂) + ", " + ... + repr(Vₙ) + "]"
, whererepr(Vᵢ)
is a representation of the i-th element (using:append
).let B := string::buffer() B:append([1, 2, 3, 4]) B:rest :> "[1, 2, 3, 4]"
meth (Buffer: string::buffer):append(List: list, Sep: string)
Appends a representation of
List
toBuffer
of the formrepr(V₁) + Sep + repr(V₂) + Sep + ... + repr(Vₙ)
, whererepr(Vᵢ)
is a representation of the i-th element (using:append
).let B := string::buffer() B:append([1, 2, 3, 4], " - ") B:rest :> "1 - 2 - 3 - 4"
type list::mutable < list
TBD
meth (List: list::mutable)[Range: integer::range]: list::slice
Returns a slice of
List
starting atRange:start
and ending atRange:limit
, both inclusive. Indexing starts at1
. Negative indices are counted from the end of the list, with-1
returning the last node.meth (List: list::mutable)[From: integer, To: integer]: list::slice
Returns a slice of
List
starting atFrom
(inclusive) and ending atTo
(exclusive). Indexing starts at1
. Negative indices are counted from the end of the list, with-1
returning the last node.meth (List: list::mutable):cycle: list
Permutes
List
in place with no sub-cycles.meth (List: list::mutable):delete(Index: integer): any | nil
Removes and returns the
Index
-th value fromList
.let L := list("cake") :> ["c", "a", "k", "e"] L:delete(2) :> "a" L:delete(-1) :> "e" L :> ["c", "k"]
meth (List: list::mutable):empty: list
Removes all elements from
List
and returns it.meth (List: list::mutable):filter(Filter: function): list
Removes every
Value
fromList
for whichFunction(Value)
returnsnil
and returns those values in a new list.let L := [1, 2, 3, 4, 5, 6] L:filter(2 | _) :> [1, 3, 5] L :> [2, 4, 6]
meth (List: list::mutable):grow(Sequence: sequence, ...): list
Pushes of all of the values produced by
Sequence
ontoList
and returnsList
.let L := [1, 2, 3] L:grow(4 .. 6) :> [1, 2, 3, 4, 5, 6]
meth (List: list::mutable):permutations: sequence
Returns a sequence of all permutations of
List
, performed in-place.meth (List: list::mutable):permute: list
Deprecated since version 2.7.0: Use
List:shuffle
instead.Permutes
List
in place.meth (List: list::mutable):pop: any | nil
Removes and returns the first element of
List
ornil
if theList
is empty.meth (List: list::mutable):pop(Fn: function): any | nil
Removes and returns the first value where
Fn(Value)
is notnil
.let L := list(1 .. 10) :> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] L:pop(3 | _) :> 3 L :> [1, 2, 4, 5, 6, 7, 8, 9, 10]
meth (List: list::mutable):pull: any | nil
Removes and returns the last element of
List
ornil
if theList
is empty.meth (List: list::mutable):pull(Fn: function): any | nil
Removes and returns the last value where
Fn(Value)
is notnil
.let L := list(1 .. 10) :> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] L:pull(3 | _) :> 9 L :> [1, 2, 3, 4, 5, 6, 7, 8, 10]
meth (List: list::mutable):push(Values: any, ...): list
Pushes
Values
onto the start ofList
and returnsList
.meth (List: list::mutable):put(Values: any, ...): list
Pushes
Values
onto the end ofList
and returnsList
.meth (List: list::mutable):reverse: list
Reverses
List
in-place and returns it.meth (List: list::mutable):shuffle: list
Shuffles
List
in place.meth (List: list::mutable):sort: List
Sorts
List
in-place using<
and returns it.meth (List: list::mutable):sort(Compare: function): List
Sorts
List
in-place usingCompare
and returns it.meth (List: list::mutable):splice: list | nil
Removes all elements from
List
. Returns the removed elements as a new list.meth (List: list::mutable):splice(Index: integer, Count: integer): list | nil
Removes
Count
elements fromList
starting atIndex
. Returns the removed elements as a new list.meth (List: list::mutable):splice(Index: integer, Count: integer, Source: list::mutable): list | nil
Removes
Count
elements fromList
starting atIndex
, then inserts the elements fromSource
, leavingSource
empty. Returns the removed elements as a new list.meth (List: list::mutable):splice(Index: integer, Source: list::mutable): nil
Inserts the elements from
Source
intoList
starting atIndex
, leavingSource
empty.type list::node
A node in a
list
. Dereferencing alist::node::const
returns the corresponding value from thelist
.type list::node::mutable < list::node
A node in a
list
. Dereferencing alist::node
returns the corresponding value from thelist
. Assigning to alist::node
updates the corresponding value in thelist
.type list::node::mutable
A node in a
list
. Dereferencing alist::node
returns the corresponding value from thelist
. Assigning to alist::node
updates the corresponding value in thelist
.type list::slice
A slice of a list.
meth list(Arg₁: names)
TBD
meth (Visitor: visitor):const(List: list::mutable): list::const
Returns a new constant list containing copies of the elements of
List
created usingCopy
.meth (Visitor: visitor):copy(List: list): list
Returns a new list containing copies of the elements of
List
created usingCopy
.meth (Visitor: visitor):visit(List: list): list
Returns a new list containing copies of the elements of
List
created usingCopy
.