Creating and Modifying Tuples

elt< C | a1, a2, ..., ak > : SetCart, Elt, ..., Elt -> Tup
C ! < a1, a2, ..., ak > : SetCart, Elt, ..., Elt -> Tup
Given a cartesian product C = R 1 x ... x Rk and a sequence of elements a1, a2, ..., ak, such that ai belongs to the set Ri (i = 1, ..., k), create the tuple T = < a1, a2, ..., ak > of C.

< a1, a2, ..., ak > : Elt, ..., Elt -> Tup
Given a cartesian product C = R1 x ... x Rk and a list of elements a1, a2, ..., ak, such that ai belongs to the set Ri, (i = 1, ..., k), create the tuple T = < a1, a2, ..., ak > of C. Note that if C does not already exist, it will be created at the time this expression is evaluated.
Append(T, x) : Tup, Elt -> Tup
Return the tuple formed by adding the object x to the end of the tuple T. Note that the result lies in a new cartesian product of course.

Append(~T, x) : Tup, Elt ->
(Procedure.) Destructively add the object x to the end of the tuple T. Note that the new T lies in a new cartesian product of course.
Prune(T) : Tup -> Tup
Return the tuple formed by removing the last term of the tuple T. The length of T must be greater than 1. Note that the result lies in a new cartesian product of course.

Prune(~T) : Tup ->
(Procedure.) Destructively remove the last term of the tuple T. The length of T must be greater than 1. Note that the new T lies in a new cartesian product of course.
Flat(T) : Tup -> Tup
Construct the flattened version of the tuple T. The flattening is done in the same way as Flat, namely depth-first.

Example Tuple_Tuple (H12E2)

We build a set of pairs consisting of primes and their reciprocals.
> C := car< Integers(), RationalField() >;
> C ! < 26/13, 13/26 >;
<2, 1/2>
> S := { C | <p, 1/p> : p in [1..25] | IsPrime(p) };
> S;
{ <5, 1/5>, <7, 1/7>, <2, 1/2>, <19, 1/19>, <17, 1/17>, <23, 1/23>, <11, 1/11>,
<13, 1/13>, <3, 1/3> }
V2.28, 13 July 2023