list¶
type list < sequenceA list of elements.
meth list(Sequence: sequence, ...): listReturns 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(): listReturns an empty list.
list() :> []
meth list(Tuple: tuple): listReturns a list containing the values in
Tuple.list((1, 2, 3)) :> [1, 2, 3]
meth (A: list) != (B: list): B | nilReturns
BifA:size != B:sizeorAᵢ != Bᵢfor somei.!=([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): listReturns a new list with the elements of
List₁followed by the elements ofList₂.meth (A: list) < (B: list): B | nilReturns
BifAᵢ = Bᵢfor eachi = 1 .. j-1andAⱼ < 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 | nilReturns
BifAᵢ = Bᵢfor eachi = 1 .. j-1andAⱼ <= 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 | nilReturns
BifA:size = B:sizeandAᵢ = Bᵢfor eachi.=([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 | nilReturns
BifAᵢ = Bᵢfor eachi = 1 .. j-1andAⱼ > 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 | nilReturns
BifAᵢ = Bᵢfor eachi = 1 .. j-1andAⱼ >= 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 | nilReturns the
Index-th node inListornilifIndexis outside the interval ofList. Indexing starts at1. Negative indices are counted from the end of the list, with-1returning 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]: listReturns a list containing the
List[Indices[1]],List[Indices[2]], etc.meth (List: list)[Indices: vector]: listReturns a list containing the
List[Indices[1]],List[Indices[2]], etc.meth (List: list):backwards: SequenceReturns a sequence which will iterate over
Listbackwards.map(list("abc"):backwards) :> {3 is "c", 2 is "b", 1 is "a"}
meth (List: list):bfind(Value: any): tuple[integer, integer]Expects
Listis be already sorted according to<>. Returns(I, J)whereList[I] = Value <= List[J]. NoteIcan benilandJcan beList: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
Listis be already sorted according toCompare(which should behave like<>). Returns(I, J)whereList[I] = Value <= List[J]. NoteIcan benilandJcan beList: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: integerReturns the length of
List[1, 2, 3]:count :> 3
meth (List: list):find(Value: any): integer | nilReturns 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 | nilReturns 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):firstReturns the first value in
ListornilifListis empty.meth (List: list):first2Returns the first index and value in
ListornilifListis empty.meth (List: list):lastReturns the last value in
ListornilifListis empty.meth (List: list):last2Returns the last index and value in
ListornilifListis empty.meth (List: list):length: integerReturns the length of
List[1, 2, 3]:length :> 3
meth (List: list):precount: integerReturns the length of
List[1, 2, 3]:precount :> 3
meth (List: list):random: anyReturns a random (assignable) node from
List.let L := list("cake") :> ["c", "a", "k", "e"] L:random :> "e" L:random :> "e"
meth (Arg₁: list):subsetsTBD
meth (Arg₁: list):subsets(Arg₂: integer)TBD
meth (Buffer: string::buffer):append(List: list)Appends a representation of
ListtoBufferof 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
ListtoBufferof 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 < listTBD
meth (List: list::mutable)[Interval: integer::interval]: list::sliceReturns a slice of
Liststarting atInterval:startand ending atInterval:limit, both inclusive. Indexing starts at1. Negative indices are counted from the end of the list, with-1returning the last node.meth (List: list::mutable)[Interval: integer::range]: list::sliceReturns a slice of
Liststarting atInterval:startand ending atInterval:limit, both inclusive. Indexing starts at1. Negative indices are counted from the end of the list, with-1returning the last node.meth (List: list::mutable)[From: integer, To: integer]: list::sliceReturns a slice of
Liststarting atFrom(inclusive) and ending atTo(exclusive). Indexing starts at1. Negative indices are counted from the end of the list, with-1returning the last node.meth (List: list::mutable):cycle: listPermutes
Listin place with no sub-cycles.meth (List: list::mutable):delete(Index: integer): any | nilRemoves 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: listRemoves all elements from
Listand returns it.meth (List: list::mutable):filter(Filter: function): listRemoves every
ValuefromListfor whichFunction(Value)returnsniland 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, ...): listPushes of all of the values produced by
SequenceontoListand returnsList.let L := [1, 2, 3] L:grow(4 .. 6) :> [1, 2, 3, 4, 5, 6]
meth (List: list::mutable):insert(Index: integer, Value: any): listInserts
Valuein theIndex-th position inList.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: permutationReturns the ordering of the elements of
Listas 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): permutationReturns the ordering of the elements of
Listas a permutation, index of first element, index of second element, ..., index of last element, when compared byCompare.let L := ["D", "B", "A", "C"] :> ["D", "B", "A", "C"] L:order(>) :> <1 4 2 3>
meth (List: list::mutable):permutations: sequenceReturns a sequence of all permutations of
List, performed in-place.meth (List: list::mutable):permute: listDeprecated since version 2.7.0: Use
List:shuffleinstead.Permutes
Listin place.meth (Arg₁: list::mutable):permute(Arg₂: list)TBD
meth (Arg₁: list::mutable):permute(Arg₂: permutation)TBD
meth (List: list::mutable):pop: any | nilRemoves and returns the first element of
Listornilif theListis empty.meth (List: list::mutable):pop(Fn: function): any | nilRemoves 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 | nilRemoves and returns the last element of
Listornilif theListis empty.meth (List: list::mutable):pull(Fn: function): any | nilRemoves 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, ...): listPushes
Valuesonto the start ofListand returnsList.meth (List: list::mutable):put(Values: any, ...): listPushes
Valuesonto the end ofListand returnsList.meth (List: list::mutable):remove(Filter: function): listRemoves every
ValuefromListfor whichFunction(Value)doesn't return non-niland 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: listReverses
Listin-place and returns it.meth (List: list::mutable):shuffle: listShuffles
Listin place.meth (List: list::mutable):sort: ListSorts
Listin-place using<=and returns it.meth (List: list::mutable):sort(Compare: function): ListSorts
Listin-place usingCompareand returns it.meth (List: list::mutable):sort(By: function, Order: function): ListSorts
Listin-place usingOrder(By(Vᵢ), By(Vⱼ))as the comparison function (evaluatingBy(Vᵢ)only once for eachi).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): ListSorts
Listin-place usingCompareand returns it.meth (List: list::mutable):splice: listRemoves all elements from
List. Returns the removed elements as a new list.meth (List: list::mutable):splice(Index: integer): list | nilRemoves all the elements from
Liststarting atIndex. Returns the removed elements as a new list.meth (List: list::mutable):splice(Index: integer, Count: integer): list | nilRemoves
Countelements fromListstarting atIndex. Returns the removed elements as a new list.meth (List: list::mutable):splice(Index: integer, Count: integer, Source: list::mutable): list | nilRemoves
Countelements fromListstarting atIndex, then inserts the elements fromSource, leavingSourceempty. Returns the removed elements as a new list.meth (List: list::mutable):splice(Index: integer, Source: list::mutable): nilInserts the elements from
SourceintoListstarting atIndex, leavingSourceempty.meth (List: list::mutable):take(Source: list::mutable): nilAppends the elements from
SourceontoList, leavingSourceempty.type list::nodeA node in a
list. Dereferencing alist::node::constreturns the corresponding value from thelist.type list::node::mutable < list::nodeA node in a
list. Dereferencing alist::nodereturns the corresponding value from thelist. Assigning to alist::nodeupdates the corresponding value in thelist.type list::node::mutableA node in a
list. Dereferencing alist::nodereturns the corresponding value from thelist. Assigning to alist::nodeupdates the corresponding value in thelist.type list::sliceA sub-list.
meth list(Arg₁: names)TBD
meth (Visitor: visitor):const(List: list::mutable): list::constReturns a new constant list containing copies of the elements of
Listcreated usingCopy.meth (Visitor: visitor):copy(List: list): listReturns a new list containing copies of the elements of
Listcreated usingCopy.meth (Visitor: visitor):visit(List: list): listReturns a new list containing copies of the elements of
Listcreated usingCopy.