Several kinds of aggregate objects are available in Magma. The bracketing for them is shown below:
The length of a set, sequence, tuple or list M is #M.
Sets and record fields are unordered; sequences, tuples and lists are ordered. The n-th entry of a sequence, tuple or list M is M[n].
All members of a set or sequence must belong to the same parent magma. The members of lists may belong to different parents. The members of tuples may belong to different parents, and these parents are the components of the Cartesian product to which the tuple belongs. The members of records are fields that have names and parents defined by the record format created for the record.
Coproducts may contain objects of entirely different types. Although the coproduct structure will serve as a single parent for such diverse objects, the proper parents of the elements are recorded internally and restored whenever the element is retrieved from the coproduct.
Enumerated set of integers: > A := { 4, 6, 2 };Sequence of permutations: > B := [ Sym(5) | (4, 1, 2), (2, 4)(1, 5) ];
Tuple belonging to the Cartesian product of the rational field and a polynomial ring: > P<x> := PolynomialRing(GF(13)); > C := < 15/8, x^5 + 3 >; > print Parent(C); Cartesian Product<Rational Field, Univariate Polynomial Algebra in x over Finite field of size 13>
A record format and record that are similar to the Cartesian product and tuple above: > F := recformat< fraction : RationalField(), poly : P >; > R := rec< F | fraction := 15/8, poly := x^5 + 3 >; > print R; rec<F | fraction := 15/8, poly := x^5 + 3>
A set constructor: > print { g : g in Sym(4) | Order(g) eq 2 }; { (1, 3)(2, 4), (2, 3), (3, 4), (1, 2), (2, 4), (1, 3), (1, 4)(2, 3), (1, 4), (1, 2)(3, 4) }