Sets are unordered lists without repeated elements.
To construct the set of all squares of integers from
to
, you could type
> S:={ 1, 4, 9, 16, 25, 36, 49, 64, 81, 100 };
or you could type
> S:={};
> for i in [1..10] do
for> S:=Include(S,i^2);
for> end for;
as in the case of lists, except we use Include rather than
Append. To find the set of all squares of integers Modulo 3
from
> S:={};
> for i in [1..10] do
for> S:=Include(S,i^2 mod 3);
for> end for;
> S;
{ 0, 1 }