Another way to define a list is to use a for loop:
> L:=[]; > for i in [1..10] do for> L[i]:=i^2; for> end for; > L; [ 1, 4, 9, 16, 25, 36, 49, 64, 81, 100 ]The first line L:=[]; is to initialize L. If omitted, MAGMA will give an error after you enter the line
for> L[i]:=i^2;. The append command also works:
> L:=[]; > for i in [1..10] do for> L:=Append(L,i^2); for> end for;Using the ``tilde'' notation, a similar command produces the same result:
> L:=[]; > for i in [1..10] do for> Append(~L,i^2); for> end for;