New Features:
Dual iteration is indicated using the arrow operator ->. Some trivial examples of its use are below.
> P := PrimesUpTo(10);
> for i->p in P do
> printf "Prime %o is %o\n", i, p;
> end for;
Prime 1 is 2
Prime 2 is 3
Prime 3 is 5
Prime 4 is 7
> M := Multiset(Eltseq("hello world"));
> for c->count in M do
> if count eq 1 then
> isare := "is"; plural := "";
> else
> isare := "are"; plural := "s";
> end if;
> printf "There %o %o '%o'%o\n", isare, count, c, plural;
> end for;
There is 1 ' '
There is 1 'e'
There are 3 'l's
There is 1 'w'
There is 1 'h'
There are 2 'o's
There is 1 'd'
There is 1 'r'
> S := [];
> for k in [1..3] do S[k^2] := k; end for;
> S;
[ 1, undef, undef, 2, undef, undef, undef, undef, 3 ]
> valid_indices := [ i : i->_ in S ];
> valid_indices;
[ 1, 4, 9 ]
Similarly, a new function Time has also been added, which is
used in a similar way to Cputime and Realtime: by first
setting a variable such as T
A simple example of the behaviour is the following:
> X := Random(MatrixRing(GF(5), 10000));
> time P := X*X; // single thread, normal CPU time
Time: 4.060
> T := Time(); P := X*X; Time(T); // similar with Time() function
4.060
> SetNthreads(8);
> time P := X*X; // multi-threads, so real time shown by [r]
Time: 1.050[r]
> T := Time(); P := X*X; Time(T); // similar with Time() function
1.050[r]
Bug Fixes: