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)[Indices: vector]: list

Returns a list containing the List[Indices[1]], List[Indices[2]], etc.

meth (List: list):backwards: Sequence

Returns a sequence which will iterate over List backwards.

map(list("abc"):backwards)
:> {3 is "c", 2 is "b", 1 is "a"}
meth (List: list):bfind(Value: any): tuple[integer, integer]

Expects List is be already sorted according to <>. Returns (I, J) where List[I] = Value <= List[J]. Note I can be nil and J can be List:length + 1.

let L := list("cake"):sort :> ["a", "c", "e", "k"]
L:bfind("a") :> (1, 1)
L:bfind("b") :> (nil, 2)
L:bfind("c") :> (2, 2)
L:bfind("z") :> (nil, 5)
meth (List: list):bfind(Value: any, Compare: function): tuple[integer, integer]

Expects List is be already sorted according to Compare (which should behave like <>). Returns (I, J) where List[I] = Value <= List[J]. Note I can be nil and J can be List:length + 1.

let L := list("cake"):sort :> ["a", "c", "e", "k"]
L:bfind("a", <>) :> (1, 1)
L:bfind("b", <>) :> (nil, 2)
L:bfind("c", <>) :> (2, 2)
L:bfind("z", <>) :> (nil, 5)
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.

let L := list("cake") :> ["c", "a", "k", "e"]
L:find("a") :> 2
L:find("b") :> nil
meth (List: list):find(Value: any, Compare: function): integer | nil

Returns the first position where Compare(Value, List[Position]) returns a non-nil value.

let L := list("cake") :> ["c", "a", "k", "e"]
L:find("b", <) :> 1
L:find("b", >) :> 2
meth (List: list):first

Returns the first value in List or nil if List is empty.

meth (List: list):first2

Returns the first index and 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):last2

Returns the last index and 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]:precount :> 3
meth (List: list):random: any

Returns a random (assignable) node from List.

let L := list("cake") :> ["c", "a", "k", "e"]
L:random :> "e"
L:random :> "e"
meth (Arg₁: list):subsets

TBD

meth (Arg₁: list):subsets(Arg₂: integer)

TBD

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):insert(Index: integer, Value: any): list

Inserts Value in the Index-th position in List.

let L := list("cake") :> ["c", "a", "k", "e"]
L:insert(2, "b") :> ["c", "b", "a", "k", "e"]
L:insert(-2, "f") :> ["c", "b", "a", "f", "k", "e"]
L :> ["c", "b", "a", "f", "k", "e"]
meth (List: list::mutable):order: permutation

Returns the ordering of the elements of List as a permutation, index of first element, index of second element, ..., index of last element, when compared by <=.

let L := ["D", "B", "A", "C"] :> ["D", "B", "A", "C"]
L:order :> <3 2 4 1>
meth (List: list::mutable):order(Compare: function): permutation

Returns the ordering of the elements of List as a permutation, index of first element, index of second element, ..., index of last element, when compared by Compare.

let L := ["D", "B", "A", "C"] :> ["D", "B", "A", "C"]
L:order(>) :> <1 4 2 3>
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 (Arg₁: list::mutable):permute(Arg₂: list)

TBD

meth (Arg₁: list::mutable):permute(Arg₂: permutation)

TBD

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) doesn't return 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):sort(By: function, Order: function): List

Sorts List in-place using Order(By(Vᵢ), By(Vⱼ)) as the comparison function (evaluating By(Vᵢ) only once for each i).

let L := ["The", "capital", "of", "Ireland", "is", "Dublin"]
:> ["The", "capital", "of", "Ireland", "is", "Dublin"]
L:sort(:upper, <)
:> ["capital", "Dublin", "Ireland", "is", "of", "The"]
meth (List: list::mutable):sort(Compare: method): List

Sorts List in-place using Compare and returns it.

meth (List: list::mutable):splice: list

Removes all elements from List. Returns the removed elements as a new list.

meth (List: list::mutable):splice(Index: integer): list | nil

Removes all the elements from List starting at Index. 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.

meth (List: list::mutable):take(Source: list::mutable): nil

Appends the elements from Source onto List, 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 < 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::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::slice

A sub-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.