I would like to define a free group on a custom ordered list of symbols, like say
Frgp=Groups()free([f'a{j}' for j in range (5,10)])
i.e. a5
up to a9
(say). It's important that the list be defined programmatically as above, as the number of generators changes throughout the program run (their labels also need to change).
I would then like to recover elements of the group by evaluating at numbered lists, as in Frgp([1,2])
to get back a5*a6
, say, as suggested in the docs. This syntax of Frgp(<numerical list>)
, however, only works when I define the group via one of the methods
Frgp.<x,y,z> = Groups().free()
or
Frgp=Groups().free(3,'t')
which are not flexible enough to allow me to interpolate strings in variable names (or are they? I have tried all sorts of eval
/exec
trickery to no avail).
If I define the group as in my preferred style (first code display above), then
sage: Frgp=Groups()free([f'a{j}' for j in range (5,10)])
sage: Frgp([1,2])
results in an error:
TypeError: 'sage.rings.integer.Integer' object is not iterable