Creation of New Lists

Here, S denotes the list [* s1, ..., sn *], while T denotes the list [* t1, ..., tm *].

S cat T : List, List -> List
The list formed by concatenating the terms of the list S with the terms of the list T, i.e. the list [* s1, ..., sn, t1, ..., tm *].
S cat:= T : List, List ->
(Procedure.) Destructively concatenate the terms of the list T to S; i.e. so S becomes the list [* s1, ..., sn, t1, ..., tm *].
Append(S, x) : List, Elt -> List
The list formed by adding the object x to the end of the list S, i.e. the list [* s1, ... sn, x *].
Append(~S, x) : List, Elt ->
(Procedure.) Destructively add the object x to the end of the list S; i.e. so S becomes the list [* s1, ... sn, x *].
Insert(~S, i, x) : List, RngIntElt, Any ->
Insert(S, i, x) : List, RngIntElt, Any -> List
Create the list formed by inserting the object x at position i in S and moving the terms S[i], ..., S[n] down one place, i.e., the list [* s1, ..., si - 1, x, si, ..., sn *]. Note that i must not be bigger than n + 1 where n is the length of S.

There are two versions of this: a procedure, where S is replaced by the new list, and a function, which returns the new list. The procedural version takes a reference ~S to S as an argument.

Note that the procedural version is much more efficient since the list S will not be copied.

Prune(S) : List -> List
The list formed by removing the last term of the list S, i.e. the list [* s1, ..., sn - 1 *].
Prune(~S) : List ->
(Procedure.) Destructively remove the last term of the list S; i.e. so S becomes the list [* s1, ..., sn - 1 *].
SequenceToList(Q) : SeqEnum -> List
Seqlist(Q) : SeqEnum -> List
Given a sequence Q, construct a list whose terms are the elements of Q taken in the same order.
TupleToList(T) : Tup -> List
Tuplist(T) : Tup -> List
Given a tuple T, construct a list whose terms are the elements of T taken in the same order.
Reverse(L) : List -> List
Given a list L return the same list, but in reverse order.
V2.28, 13 July 2023