Use of ![1] syntax in GAP

80 Views Asked by At

What is the use of ![1] in GAP?

It is used in many source files.

gap> f:=FreeGroup( 4 );
<free group on the generators [ f1, f2, f3, f4 ]>
gap> f.1![1];
"\>"
gap> f.2![1];
"\<"
gap>

It is also for checking the equality of two FreeGroup elements (associative words) in source of GAP. It is undocumented in GAP (seems like, as i tried or may be i don't know its method). To my understanding it seems some conversion to unicode characters. If possible also please mention the corresponding function in Python. Thanks

Note: To those who think why i didn't ask this question on GAP forum. I must mention that "I also asked some other question of GAP on GAP forum but got no reply, it's been 1 week (i know GAP is open source), but the swiftness with which i get answers to my question on this site got me ask it here.

1

There are 1 best solutions below

1
On

For an object stored internally in the format of a list, A![1] accesses the internal storage (in component 1 etc.) of this object. Groups (such as the free group in you example) are not stored in this format, so the data in your example is not really meaningful but the equivalent of a random Peek in BASIC. The representation as unicode is a side effect of having to represent somewhat random bytes.

(For objects, such a groups, that are stored based on the record format, A!.componentname is an analog construct.)

In general objects have proper functions to access their internal data structures. So unless you are working with very low level code (and know these internal data structures) there is no reason to use the ! operator.