up previous next

group several commands into a single command

block C_1; ... ; C_n EndBlock;

where each C_i is a command.

The block command executes the commands as if they where one command. What this means in practice is that CoCoA will not print a string of dashes after executing each C_i . Thus, Block is used on-the-fly and not inside user-defined functions. (It has nothing to do with declaration of local variables, for instance, as one might infer from some other computer languages.) The following example should make the use of Block clear:

/**/  Print "hello "; Print "world";
hello world
/**/  Block
/**/    Print "hello ";
/**/    Print "world";
/**/  EndBlock;
hello world
/**/  use QQ[x,y];
/**/  Block
/**/    PrintLn GCD([12, 24, 96]);
/**/    PrintLn LCM([12, 24, 96]);
/**/    PrintLn GCD([x+y, x^2-y^2]);
/**/    Print LCM([x+y, x^2-y^2]);
/**/  EndBlock;

x + y
x^2 - y^2