Answer

问题及解答

GAP 的输入规则

Posted by haifeng on 2011-07-01 16:32:39 last update 2011-08-06 15:06:26 | Edit | Answers (3)

  • 提示符gap>下输入的语句指以分号结束的字符串。
  • 如果使计算结果不显示,只需在语句末连续加两个分号。
  • GAP对于输入的语句首先检查其语法正确性,然后再进行计算、输出。如果在一行中输入了两个语句,则第二个语句的语法检查只能等到第一句计算结束之后才能执行。
  • GAP对输入语句的语法检查通常会明确指出为何出错,在何处出错。
  • 在多语句执行后,可以用last,last2,last3分别指代倒数第一、二、三个语句的值。但是如last4、last5等就不支持了。例如r
    gap> 1;2;3;4;5;
    1
    2
    3
    4
    5
    gap> last+last2*2+last3*3+last4*4+last5*5;
    Variable: \'last4\' must have a value
    
    gap> last+last2*2+last3*3;                
    22
    gap> 
    

GAP 的其他特殊输入规则参见 answers.

1

Posted by haifeng on 2011-07-01 16:59:58

GAP输入的特殊规则

某些GAP对象的输入可能不适合在一行输入,如大整数、长字符串、长标识符。在这种情况下,你虽然也可以将它们在一行内输入,但是当超过一定长度后,在屏幕上显示的是以$为开头的字串,如

gap> $11111111111111111111*9;                                                
999999999999999999999999999999999999999999999999999999999999999999999999999999\
9999999999

这里其实是输入了

111111111111111111111111111111111111111111111111111111111111111111111111111111\
1111111111*9;

此时如果想明确显示自己的输入,则可以在行末加上一个反斜杠\ 或反斜杠与回车符,如

gap> 12345678901234567890123456789012345678901234567890\
gap> 123456789012345678901234567890123456789012345678901234567890\
gap> 1234567890123456789012345678901234567890;
123456789012345678901234567890123456789012345678901234567890123456789012345678\
901234567890123456789012345678901234567890123456789012345678901234567890

GAP对于长整数、长字符串的输出也是按照这种规则的。

2

Posted by haifeng on 2011-08-06 15:05:08

Special Rule

对于输入行中的 GAP 提示符有一个特殊规则:

在行编辑模式中(即通常用户在输入时或者GAP启动时未带参数 -n), 在行中如有以 gap>, > 或 brk> 开始的语句, 开头部分是要被去掉的.

这个规则是非常方便的, 因为这可以将其他 GAP sessions 或 manual examples 中的输入轻松地剪切或拷贝到当前 session 中.

3

Posted by haifeng on 2011-07-01 17:07:21

Special Rule

There is a special rule about GAP prompts in input lines: In line editing mode (usual user input and GAP
started without -n) in lines starting with gap> , > or brk> this beginning part is removed. This rule is
very convenient because it allows to cut and paste input from other GAP sessions or manual examples easily into your current session.