[GAP Forum] A Question about For Loops
Alexander Konovalov
alexk at mcs.st-andrews.ac.uk
Tue Feb 11 11:41:36 GMT 2014
Dear Minghui Liu,
On 11 Feb 2014, at 11:31, Minghui Liu <matliumh at gmail.com> wrote:
> Dear All,
>
> In GAP I would like to create a free group with 200 generators and call the
> nth generator dn. I tried the following commands but it does not work:
>
> gap> F:=FreeGroup(200);
> gap> a:=[1..200];
> gap> for x in a do
>> dx:=F.x;
>> od;
>
> The error message is
The reason is that GAP parses F.x as an access to the component 'x' of the
object F. Clearly that does not work in this context. To enforce evaluation
of x to get F.1, F.2 etc, use F.(x), for example
gap> F:=FreeGroup(200);
<free group with 200 generators>
gap> a:=[1..200];
[ 1 .. 200 ]
gap> for x in a do
> dx:=F.(x);
> od;
gap> dx;
f200
The difference between r.name and r.(name) constructions is explained in
"29.2 Accessing Record Elements" in the reference manual.
Hope this helps
Alexander
More information about the Forum
mailing list