To create the set
> L:=[]; > for i in [1..10] do for> L:=Append(L,i^2); for> end for; > M:=[]; > for i in [-2..6] do for> M:=Append(M,i); for> end for; > LxM:=[<x,y>:x in L,y in M];Now > LxM; will return
[ <1, -2>, <4, -2>, <9, -2>, <16, -2>, <25, -2>, <36, -2>, <49, -2>, <64, -2>, <81, -2>, <100, -2>, <1, -1>, <4, -1>, <9, -1>, <16, -1>, <25, -1>, <36, -1>, <49, -1>, <64, -1>, <81, -1>, <100, -1>, <1, 0>, <4, 0>, <9, 0>, <16, 0>, <25, 0>, <36, 0>, <49, 0>, <64, 0>, <81, 0>, <100, 0>, <1, 1>, <4, 1>, <9, 1>, <16, 1>, <25, 1>, <36, 1>, <49, 1>, <64, 1>, <81, 1>, <100, 1>, <1, 2>, <4, 2>, <9, 2>, <16, 2>, <25, 2>, <36, 2>, <49, 2>, <64, 2>, <81, 2>, <100, 2>, <1, 3>, <4, 3>, <9, 3>, <16, 3>, <25, 3>, <36, 3>, <49, 3>, <64, 3>, <81, 3>, <100, 3>, <1, 4>, <4, 4>, <9, 4>, <16, 4>, <25, 4>, <36, 4>, <49, 4>, <64, 4>, <81, 4>, <100, 4>, <1, 5>, <4, 5>, <9, 5>, <16, 5>, <25, 5>, <36, 5>, <49, 5>, <64, 5>, <81, 5>, <100, 5>, <1, 6>, <4, 6>, <9, 6>, <16, 6>, <25, 6>, <36, 6>, <49, 6>, <64, 6>, <81, 6>, <100, 6> ]
There are also commands CartesianProduct and
CartesianPower in MAGMA. However,
they do not return a list or sequence structure,
even if you are taking the cartesian product of lists.