Top
Back: 5.2.5 export
Forward: 5.2.7 if
FastBack: 5. Functions and system variables
FastForward: 6. Tricks and pitfalls
Up: 5.2 Control structures
Top: Singular 2-0-4 Manual
Contents: Table of Contents
Index: F. Index
About: About This Document

5.2.6 for

Syntax:

for ( init_command; boolean_expression; iterate_commands) block

Purpose:

repetitive, conditional execution of a command block.
The command init_command is executed first. Then boolean_expression is evaluated. If its value is TRUE the block is executed, otherwise the for statement is complete. After each execution of the block, the command iterate_command is executed and boolean_expression is evaluated. This is repeated until boolean_expression evaluates to FALSE.
The command break; leaves the innermost for construct.

Example:
 
// sum of 1 to 10:
int s=0;
for (int i=1; i<=10; i=i+1)
{
   s=s+i;
}
s;
→ 55

See Control structures; boolean expressions; break; continue; if; while.


Top Back: 5.2.5 export Forward: 5.2.7 if FastBack: 5. Functions and system variables FastForward: 6. Tricks and pitfalls Up: 5.2 Control structures Top: Singular 2-0-4 Manual Contents: Table of Contents Index: F. Index About: About This Document
            User manual for Singular version 2-0-4, October 2002, generated by texi2html.