CoCoA:Block

From ApCoCoAWiki
Revision as of 10:02, 24 October 2007 by XMLBot (talk | contribs) (pushing XML rev. 1.46, again)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Block

group several commands into a single command

Description

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:

Example

  Print <quotes>hello </quotes>; Print <quotes>world</quotes>;
hello
-------------------------------
world
-------------------------------
  Block
    Print <quotes>hello </quotes>;
    Print <quotes>world</quotes>;
  EndBlock;
hello world
-------------------------------
  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;

12
96
x + y
x^2 - y^2
-------------------------------

Syntax

Block C_1; ... ; C_n EndBlock;

where each C_i is a command.
   <type>io</type>
   <type>miscellaneous</type>
   <type>printing</type>