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 (A: list) != (B: list): B | nil

Returns B if A:size != B:size or Aᵢ != Bᵢ for some i.

!=([1, 2, 3], [1, 2, 3]) :> nil
!=([1, 2, 3], [1, 2]) :> [1, 2]
!=([1, 2], [1, 2, 3]) :> [1, 2, 3]
!=([1, 2, 3], [1, 2, 4]) :> [1, 2, 4]
!=([1, 3, 2], [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 of List₂.

meth (A: list) < (B: list): B | nil

Returns B if Aᵢ = Bᵢ for each i = 1 .. j-1 and Aⱼ < Bⱼ.

<([1, 2, 3], [1, 2, 3]) :> nil
<([1, 2, 3], [1, 2]) :> nil
<([1, 2], [1, 2, 3]) :> [1, 2, 3]
<([1, 2, 3], [1, 2, 4]) :> [1, 2, 4]
<([1, 3, 2], [1, 2, 3]) :> nil
meth (A: list) <= (B: list): B | nil

Returns B if Aᵢ = Bᵢ for each i = 1 .. j-1 and Aⱼ <= Bⱼ.

<=([1, 2, 3], [1, 2, 3]) :> [1, 2, 3]
<=([1, 2, 3], [1, 2]) :> nil
<=([1, 2], [1, 2, 3]) :> [1, 2, 3]
<=([1, 2, 3], [1, 2, 4]) :> [1, 2, 4]
<=([1, 3, 2], [1, 2, 3]) :> nil
meth (A: list) = (B: list): B | nil

Returns B if A:size = B:size and Aᵢ = Bᵢ for each i.

=([1, 2, 3], [1, 2, 3]) :> [1, 2, 3]
=([1, 2, 3], [1, 2]) :> nil
=([1, 2], [1, 2, 3]) :> nil
=([1, 2, 3], [1, 2, 4]) :> nil
=([1, 3, 2], [1, 2, 3]) :> nil
meth (A: list) > (B: list): B | nil

Returns B if Aᵢ = Bᵢ for each i = 1 .. j-1 and Aⱼ > Bⱼ.

>([1, 2, 3], [1, 2, 3]) :> nil
>([1, 2, 3], [1, 2]) :> [1, 2]
>([1, 2], [1, 2, 3]) :> nil
>([1, 2, 3], [1, 2, 4]) :> nil
>([1, 3, 2], [1, 2, 3]) :> [1, 2, 3]
meth (A: list) >= (B: list): B | nil

Returns B if Aᵢ = Bᵢ for each i = 1 .. j-1 and Aⱼ >= Bⱼ.

>=([1, 2, 3], [1, 2, 3]) :> [1, 2, 3]
>=([1, 2, 3], [1, 2]) :> [1, 2]
>=([1, 2], [1, 2, 3]) :> nil
>=([1, 2, 3], [1, 2, 4]) :> nil
>=([1, 3, 2], [1, 2, 3]) :> [1, 2, 3]
meth (List: list)[Index: integer]: list::node | nil

Returns the Index-th node in List or nil if Index is outside the interval of List. Indexing starts at 1. 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]: 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 or nil if List is empty.

meth (List: list):last

Returns the last value in List or nil if List 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 to Buffer of the form "[" + repr(V₁) + ", " + repr(V₂) + ", " + ... + repr(Vₙ) + "]", where repr(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 to Buffer of the form repr(V₁) + Sep + repr(V₂) + Sep + ... + repr(Vₙ), where repr(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)[Interval: integer::interval]: list::slice

Returns a slice of List starting at Interval:start and ending at Interval:limit, both inclusive. Indexing starts at 1. Negative indices are counted from the end of the list, with -1 returning the last node.

meth (List: list::mutable)[Interval: integer::range]: list::slice

Returns a slice of List starting at Interval:start and ending at Interval:limit, both inclusive. Indexing starts at 1. 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 at From (inclusive) and ending at To (exclusive). Indexing starts at 1. 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 from List.

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 from List for which Function(Value) returns nil 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 onto List and returns List.

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 or nil if the List is empty.

meth (List: list::mutable):pop(Fn: function): any | nil

Removes and returns the first value where Fn(Value) is not nil.

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 or nil if the List is empty.

meth (List: list::mutable):pull(Fn: function): any | nil

Removes and returns the last value where Fn(Value) is not nil.

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 of List and returns List.

meth (List: list::mutable):put(Values: any, ...): list

Pushes Values onto the end of List and returns List.

meth (List: list::mutable):remove(Filter: function): list

Removes every Value from List for which Function(Value) returns non-nil and returns those values in a new list.

let L := [1, 2, 3, 4, 5, 6]
L:remove(2 | _) :> [2, 4, 6]
L :> [1, 3, 5]
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 using Compare 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 from List starting at Index. 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 from List starting at Index, then inserts the elements from Source, leaving Source 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 into List starting at Index, leaving Source empty.

type list::node

A node in a list. Dereferencing a list::node::const returns the corresponding value from the list.

type list::node::mutable

A node in a list. Dereferencing a list::node returns the corresponding value from the list. Assigning to a list::node updates the corresponding value in the list.

type list::node::mutable < list::node

A node in a list. Dereferencing a list::node returns the corresponding value from the list. Assigning to a list::node updates the corresponding value in the list.

type list::skip < sequence

TBD

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 using Copy.

meth (Visitor: visitor):copy(List: list): list

Returns a new list containing copies of the elements of List created using Copy.

meth (Visitor: visitor):visit(List: list): list

Returns a new list containing copies of the elements of List created using Copy.