I want to say a little bit more about iterators in GAP.
Our plans are as follows. There will be a function 'Iterator'. This
function can be applied to any domain. It returns an iterator, which is
represented by record of course. You can apply two functions to such an
iterator, 'IsDone' and 'Next'. The first call to 'Next' returns the
first element of the domain, successive calls to 'Next' return the other
elements of the domain. 'IsDone' returns 'true' until all elements of
the domain have been returned by 'Next'. So you can write a 'while'-loop
to iterate over all elements of a domain <D> as follows
iter := Iterator( <D> ); while not IsDone( iter ) do elm := Next( iter ); <do something with elm> od;
This can also be abbreviated with the 'for'-loop (for that we will have
to extend the kernel a little bit)
for elm in <D> do <do something with elm> od;
One thing that we have not yet decided is whether the iterator should
return the elements in order, i.e., smallest element first.
Another problem is that the iterator mustn't use data from the domain
that may change. For example the iterator for a permutation group
mustn't use the stabilizer chain of that permutation group, instead it
must make a copy of the stabilizer chain first.
Iterators aren't on top of the priority list, because we found that we
can get by without them. One reason is that for those groups where we
know how to do an iteration well, i.e., permutation groups and AG groups,
those functions that could make use of an iterator have the iteration
hardcoded into them already. Especially for permutation groups this is
necessary so that they can do without copying the stabilizer chain first.
However iterators aren't at the bottom of our priority list either.
(What is at the bottom of our priority list? Well I don't know. And I
cant look, 'bert' has only 3 MByte space on its harddisk free currently,
which isn't enough to load the to-do list from the backup ;-)
Martin Sch"onert, Martin.Schoenert@Math.RWTH-Aachen.DE, +49 241 804551
Lehrstuhl D f"ur Mathematik, Templergraben 64, RWTH, D 51 Aachen, Germany