[GAP Forum] A plain set of objects

Alexander Konovalov alexander.konovalov at gmail.com
Wed Mar 4 17:50:37 GMT 2009


Dear Levi,

On 24 Feb 2009, at 07:35, Levie Bicua wrote:

> Dear forum,
> I'm wondering if there is a more efficient way of defining in GAP a  
> simple set of objects without necessarily using the quotation marks  
> for each element of the set. For example I want to define/write in  
> GAP the set S1={ P, Q, RPR, RQPQPQR, RQPRPQR, RQRPRQR, RQRQRQR }.
>
> gap> S1:={P,Q,RPR,RQPQPQR,RQPRPQR,RQRPRQR,RQRQRQR};
> Syntax error: literal expected
> S1:={P,Q,RPR,RQPQPQR,RQPRPQR,RQRPRQR,RQRQRQR};
> ^

First, this syntax fails not because of quotation marks missing, but
because of the improper use of { ... } brackets. In GAP the sets are
special kind of lists, and lists are created using [ ... ] brackets.
So, first, using the right kind of brackets, you will get the following
error:

gap> S1:=[P,Q,RPR,RQPQPQR,RQPRPQR,RQRPRQR,RQRQRQR];
Error, Variable: 'Q' must have a value
not in any function

Now the reason is that there is no variable with the identifier 'Q',
so you can not use it in expressions. The same will happen with the
rest of the list after Q (GAP does not complain about P only because
there is a function with the name 'P' in gap4r4/lib/obsolete.g, which
came from one of earlier releases and will be eventually eliminated).

> gap> S1:=["P","Q","RPR","RQPQPQR","RQPRPQR","RQRPRQR","RQRQRQR"];
> [ "P", "Q", "RPR", "RQPQPQR", "RQPRPQR", "RQRPRQR", "RQRQRQR" ].
> Enclosing each element by a quotation mark requires much time  
> especially for a large set. any help? thanks.
>

What you did here is that you created a list of *strings*. So you
have an objects of a particular kind, which are just ordered
sequences of symbols. Is this really what you would like to achieve?
I have an impression that you would like to write words in group
generators, does the reference manual chapter

http://www.gap-system.org/Manuals/doc/htm/ref/CHAP034.htm

and subsequent ones help?

Best wishes,
Alexander



More information about the Forum mailing list